这个程序超时了(75分)。谁能帮我改改啊!

const

maxn = 1000;

var

a,b,c : array[1..maxn] of byte;

i,j,w1,w2 : integer;

ch : char;

begin

Write(' a = ');

w1 := 0;

while not eoln do begin

read(ch);

inc(w1);

c[w1] := ord(ch)-48;

end;

readln;

for i := 1 to w1 do a[w1+1-i] := c[i];

Write(' b = ');

w2 := 0;

while not eoln do begin

read(ch);

inc(w2);

c[w2] := ord(ch)-48;

end;

readln;

for i := 1 to w2 do b[w2+1-i] := c[i];

fillchar(c,sizeof(c),0);

for j := 1 to w2 do begin

for i := 1 to w1 do

c := c+a[i]*b[j];

for i := 1 to j+w1 do

if c[i] > 9 then begin

c := c+c[i] div 10;

c[i] := c[i] mod 10;

end;

end;

j := w1+w2;

while c[j] = 0 do dec(j);

write('a*b = ');

for i := j downto 1 do Write(c[i]);

WriteLn;

ReadLn;

end.

1 条评论

  • 1

信息

ID
1040
难度
7
分类
高精度 点击显示
标签
(无)
递交数
16568
已通过
3173
通过率
19%
被复制
26
上传者