为了账号安全,请及时绑定邮箱和手机立即绑定

求助,关于pascal高精乘(函数)!

求助,关于pascal高精乘(函数)!

千巷猫影 2021-09-20 14:10:15
麻烦告诉一下!~谢谢
查看完整描述

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.



查看完整回答
反对 回复 2021-09-23
?
饮歌长啸

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.



查看完整回答
反对 回复 2021-09-23
  • 2 回答
  • 0 关注
  • 199 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信