pascal 加法程序,简练,明了!
pascal吧
全部回复
仅看楼主
level 3
ai21faraway 楼主
999999999888888887777777666666555554444333221+99999999999999999999=?
2012年03月01日 13点03分 1
level 6

我要吧主……………………
2012年03月01日 14点03分 2
level 6
要程序么?
var a,b:array[0..5000]of integer;
h1,h2,i,t,h:longint;
c:char;
begin
read(c);
while c<>'+' do begin inc(h1); a[h1]:=ord(c)-ord('0');read(c); end;
read(c);
while c<>'=' do begin inc(h2);b[h2]:=ord(c)-ord('0');read(c);end;
for i:=1 to h1 div 2 do
t:=a[i];a[i]:=a[h1-i+1];a[h1-i+1]:=t;
for i:=1 to h2 div 2 do
t:=b[i];b[i]:=b[h2-i+1];b[h2-i+1]:=t;
if h1>h2 then h:=h1 else h:=h2;
for i:=1 to h do
a[i]:=a[i]+b[i];
for i:=1 to h+1 do
if a[i]>=10 then begin a[i+1]:=a[i]div 10;a[i]:=a[i]mod 10;end;
h:=h+2;
while (a[h]=0)and(h>0) do dec(h);
for i:=h downto 1 do write(a[i]);
writeln;
end.
大概………………就是这样吧………………没有运行,可能会出错………………如果有问题再来找我吧

2012年03月02日 10点03分 3
level 3
ai21faraway 楼主
谢谢!!
2012年03月02日 14点03分 4
level 5
高精度啊
2012年03月03日 13点03分 5
level 3
ai21faraway 楼主
没有叫哥,也没有叫爷,乃宿生万幸
2012年03月12日 12点03分 7
level 4
program Main;
var a,b:array[0..5000]of integer;
h1,h2,i,t,h:longint;
c:char;
begin
read(c);
while c<>'+' do begin inc(h1); a[h1]:=ord(c)-ord('0');read(c); end;
read(c);
while c<>'=' do begin inc(h2);b[h2]:=ord(c)-ord('0');read(c);end;
for i:=1 to h1 div 2 do
t:=a[i];a[i]:=a[h1-i+1];a[h1-i+1]:=t;
for i:=1 to h2 div 2 do
t:=b[i];b[i]:=b[h2-i+1];b[h2-i+1]:=t;
if h1>h2 then h:=h1 else h:=h2;
for i:=1 to h do
a[i]:=a[i]+b[i];
for i:=1 to h+1 do
if a[i]>=10 then begin a[i+1]:=a[i]div 10;a[i]:=a[i]mod 10;end;
h:=h+2;
while (a[h]=0)and(h>0) do dec(h);
for i:=h downto 1 do write(a[i]);
writeln;
end.
2022年03月13日 01点03分 9
level 4
第六行出错
2022年03月13日 01点03分 10
十年洛阳铲,真有你的
2022年03月13日 12点03分
1