高手写的所有acm例程 在acm.zju.edu.cn 上的题目的例程

源代码在线查看: p1073.dpr

软件大小: 430 K
上传用户: foreverxiluzai
关键词: acm zju edu cn
下载地址: 免注册下载 普通下载 VIP

相关代码

				PROGRAM p1073;
				
				{$APPTYPE CONSOLE}
				
				
				
				VAR
				   num,sum  :array[1..60]of integer;
				   long :integer;
				   ch   :char;
				   i    :integer;
				   pack,temp :array[0..9]of integer;
				
				FUNCTION check:boolean;
				var
				   i    :integer;
				   add  :integer;
				   step :integer;
				begin
				check:=true;
				fillchar(pack,sizeof(pack),0);
				for i:=1 to long do
				    begin
				    sum[i]:=num[i];
				    inc(pack[sum[i]]);
				    end;
				step:=1;
				while step				begin
				add:=0;
				inc(step);
				for i:=long downto 1 do
				    begin
				    add:=sum[i]+num[i]+add;
				    sum[i]:=add mod 10;
				    add:=add div 10;
				    end;
				if add=0 then
				   begin
				   fillchar(temp,sizeof(temp),0);
				   for i:=1 to long do inc(temp[sum[i]]);
				   for I:=0 to 9 do
				       if temp[i]pack[i] then
				       begin
				       check:=false;
				       exit;
				       end;
				   end else
				        begin
				        if step=long then
				                begin
				                check:=true;
				                end else
				                begin
				                check:=false;
				                exit;
				                end;
				        end;
				end;
				end;
				
				
				BEGIN
				while not eof do
				      begin
				      long:=0;
				      while not eoln do
				            begin
				            read(ch);
				            inc(long);
				            num[long]:=ord(ch)-48;
				            end;
				      readln;
				      for i:=1 to long do write(num[i]);
				      if check then writeln(' is cyclic') else writeln(' is not cyclic');
				      end;
				END.
				
							

相关资源