|
|
вернуться в форумwhy I got CE?Help please! Послано SunCat 12 ноя 2002 19:23 program Ural1014; var result,work:array[1..40] of byte; n:longint; mstep:integer; function search(t:integer;rest,last:longint):boolean; var i:integer; temp:boolean; begin if t=mstep+1 then begin if rest=1 then begin result:=work;search:=true end else search:=false; exit; end else begin for i:=last to 9 do if rest mod i =0 then begin work[t]:=i; temp:=search(t+1,rest div i,i); if temp then begin search:=true;exit end; end; end; end; procedure print; var i:integer; begin for i:=1 to mstep do write(result[i]); writeln; end; begin fillchar(result,sizeof(result),0); fillchar(work,sizeof(work),0); readln(n); if n=0 then begin writeln(10);exit end else for mstep:=1 to 30 do if search(1,n,2) then begin print;exit end; writeln(-1); end. Cange result to result1 and see in function seerch. maby i didn't change all reult to result1 program Ural1014; var result1,work:array[1..40] of byte; n:longint; mstep:integer;
function search(t:integer;rest,last:longint):boolean; var i,oo:integer; temp:boolean; begin if t=mstep+1 then begin if rest=1 then begin for oo:=1 to 40 do result1[oo]:=work[oo]; search:=true end else search:=false; exit; end else begin for i:=last to 9 do if rest mod i =0 then begin work[t]:=i; temp:=search(t+1,rest div i,i); if temp then begin search:=true;exit end; end; end; end;
procedure print; var i:integer; begin for i:=1 to mstep do write(result1[i]); writeln; end;
begin fillchar(result1,sizeof(result1),0); fillchar(work,sizeof(work),0); readln(n); if n=0 then begin writeln(10);exit end else for mstep:=1 to 30 do if search(1,n,2) then begin print;exit end; writeln(-1); end. |
|
|