|
|
вернуться в форумHere is my program but why it is wrong? program knumber; var k,n,i,t:integer; a,b,c:array[1..2000] of integer; procedure multiply; var i,g:longint; begin g:=0; for i:=1 to t do begin b[i]:=b[i]+a[i]+g; g:=b[i] div 10; b[i]:=b[i] mod 10; end; if g<>0 then begin inc(t); b[t]:=g; end; g:=0; for I:=1 to t do begin b[i]:=b[i]*(k-1)+g; g:=b[i] div 10; b[i]:=b[i] mod 10; end; while g<>0 do begin inc(t); b[t]:=g mod 10; g:=g div 10; end; end; begin readln(n); readln(k); a[1]:=1; t:=0;i:=k-1; while i>0 do begin inc(t); b[t]:=i mod 10; i:=i div 10; end; for i:=2 to n do begin c:=b; multiply; a:=c; end; for i:=t downto 1 do write(b[i]); writeln; end. |
|
|