- 高精度乘法
- 2009-10-30 23:23:01 @
var
x:array[0..20000] of integer;
a,b:string;
i:longint;
procedure chen(a,b:string);
var
i,j:longint;
ta,tb:longint;
begin
fillchar(x,sizeof(x),0);
for i:=1 to length(a) do
begin
val(a[i],ta);
for j:=1 to length(b) do
begin
val(b[j],tb);
x:=ta*tb+x;
end;
end;
for i:=length(a)+length(b)-1 downto 1 do
begin
x:=x+x[i] div 10;
x[i]:=x[i] mod 10;
end;
end;
begin
readln(a);
readln(b);
chen(a,b);
if x[0]=0 then
for i:=1 to length(a)+length(b)-1 do
write(x[i],' ')
else
for i:=0 to length(a)+length(b)-1 do
write(x[i]);
end.
2 条评论
-
sh_03 LV 7 @ 2009-10-31 07:28:14
应该没什么地方不对吧,估计忘了考虑A*0=0这中情况了!!
-
2009-10-31 01:26:03@
要用四位一乘
- 1