2 回答
TA贡献1828条经验 获得超4个赞
program aa;
type gao=array[1..100]of integer;
var x1,x2,y:gao;
s,s1,s2,s3:ansistring;
function cheng(a,b:ansistring):ansistring;
var i,j,x,m,n:integer;
begin
n:=length(a);
m:=length(b);
for i:=1to n do
val(a[i],x1[n-i+1]);
for i:=1to m do
val(b[i],x2[m-i+1]);
for i:=1to n do
begin
x:=0;
for j:=1to m do
begin
x:=x1[i]*x2[j]+x div 10+y[i+j-1];
y[i+j-1]:=x mod 10;
end;
y[i+j]:=x div 10;
end;
n:=m+n;
while (y[n]=0)and(n>1)do dec(n);
for i:=1to n do
begin
str(y[n-i+1],s1);
s:=s+s1;
end;
cheng:=s;
end;
begin
readln(s1);
readln(s2);
write(cheng(s1,s2));
end.
TA贡献1951条经验 获得超3个赞
program gaojinduchengfa;
var
i,j,k,l,m,n:longint;
a,b,c:array[1..200000] of longint;
x,y:array[1..100000]of char;
begin
m:=0;n:=0;
while not seekeoln do begin
inc(m);
read(x[m]);
end;
readln;
while not seekeoln do begin
inc(n);
read(y[n]);
end;
for i:=m downto 1 do a[m-i+1]:=ord(x[i])-ord('0');
for i:=n downto 1 do b[n-i+1]:=ord(y[i])-ord('0');
for i:=1 to m do
for j:=1 to n do
c[i+j-1]:=c[i+j-1]+a[i]*b[j];
for j:=1 to n+m do begin
c[j+1]:=c[j+1]+c[j] div 10;
c[j]:=c[j] mod 10;
end;
l:=m+n;
while c[l]=0 do dec(l);
for i:=l downto 1 do write(c[i]);
end.
添加回答
举报