|
|
вернуться в форумWhy I got wrong? Please help me! program p1014; var a:array[1..32]of integer; n:longint; i,j,sign,temp:integer; flag:boolean; begin readln(n); sign:=0; flag:=true; while (n>=10)and flag do begin flag:=false; for i:=9 downto 2 do if n mod i=0 then begin flag:=true; sign:=sign+1; a[sign]:=i; n:=n div i; break end end; if not flag then begin writeln('?'); halt end; sign:=sign+1; a[sign]:=n; for i:=1 to sign-1 do for j:=i+1 to sign do if a[i]>a[j] then begin temp:=a[i]; a[i]:=a[j]; a[j]:=temp end; for i:=1 to sign do write(a[i]); writeln end. Re: Why I got wrong? Please help me! > program p1014; > var > a:array[1..32]of integer; > n:longint; > i,j,sign,temp:integer; > flag:boolean; > begin > readln(n); > sign:=0; > flag:=true; > while (n>=10)and flag do > begin > flag:=false; > for i:=9 downto 2 do > if n mod i=0 then > begin > flag:=true; > sign:=sign+1; > a[sign]:=i; > n:=n div i; > break > end > end; > if not flag then > begin > writeln('?'); > halt > end; > sign:=sign+1; > a[sign]:=n; > for i:=1 to sign-1 do > for j:=i+1 to sign do > if a[i]>a[j] then > begin > temp:=a[i]; > a[i]:=a[j]; > a[j]:=temp > end; > for i:=1 to sign do > write(a[i]); > writeln > end. Your program should print to the output the only number Q. If such a number does not exist print –1. But it not all is one more test at N=0. Think! |
|
|