洛谷 P1601 A+B Problem(高精)
题目描述
高精度加法,相当于a+b problem,不用考虑负数
分析
没什么好说的,高精度
var
s1,s2:ansistring;
a,b,c:array[0..100000]of longint;
i:longint;
begin
readln(s1);
readln(s2);
a[0]:=length(s1);
b[0]:=length(s2);
for i:=a[0] downto 1 do val(s1[i],a[a[0]-i+1]);
for i:=b[0] downto 1 do val(s2[i],b[b[0]-i+1]);
if a[0]0] then c[0]:=b[0] else c[0]:=a[0];
for i:=1 to c[0] do
begin
c[i]:=a[i]+b[i]+c[i];
if c[i]>=10 then
begin
inc(c[i+1]);
c[i]:=c[i]-10;
end;
end;
if c[c[0]+1]>0 then c[0]:=c[0]+1;
for i:=c[0] downto 1 do write(c[i]);
end.