|
|
вернуться в форумwhere is wrong! Послано girl 29 окт 2002 11:01 why my program is wrong! var n,j,i:integer; a:array[1..2000] of integer; procedure cheng(x:integer); var i,g:integer; begin for i:=1 to 2000 do a[i]:=a[i]*x; for i:=1 to 2000 do begin g:=a[i] div 10; a[i+1]:=a[i+1]+g; a[i]:=a[i] mod 10; end; end; begin read(n); if n<4 then begin writeln(n); halt; end; fillchar(a,sizeof(a),0); if n>=3 then begin a[1]:=3; n:=n-3; end; while n-3>=0 do begin n:=n-3; cheng(3); end; if n<>0 then cheng(n); i:=2000; while (i>1) and (a[i]=0) do dec(i); for j:=i downto 1 do write(chr((ord(a[j])+48))); end. Chang "read" to "readln" but it got WA too. I don't no why > why my program is wrong! > var n,j,i:integer; > a:array[1..2000] of integer; > procedure cheng(x:integer); > var i,g:integer; > begin > for i:=1 to 2000 do > a[i]:=a[i]*x; > for i:=1 to 2000 do > begin > g:=a[i] div 10; > a[i+1]:=a[i+1]+g; > a[i]:=a[i] mod 10; > end; > end; > begin > readln(n); > if n<4 then > begin > writeln(n); > halt; > end; > fillchar(a,sizeof(a),0); > if n>=3 then > begin > a[1]:=3; > n:=n-3; > end; > while n-3>=0 do > begin > n:=n-3; > cheng(3); > end; > if n<>0 then cheng(n); > i:=2000; > while (i>1) and (a[i]=0) do dec(i); > for j:=i downto 1 do > write(chr((ord(a[j])+48))); > end. > I don't know but... Послано Leo 20 ноя 2002 14:02 Tip: write(chr((ord(a[j])+48))); is equal to write(a[j]); |
|
|