-
type int=longint; arr1=array[1..100000]of int; var aa:char; a,b,c:arr1; k,l1,l2,i,j,l3,p:int; s:ansistring; procedure add(var a,b,c:arr1); var k,i,j:int; begin k:=1;i:=1;j:=1; while (k<=l1)or(k<=l2)do begin c[k]:=a[k]+b[k]+c[k]; c[k+1]:=c[k] div 10; c[k]:=c[k] mod 10; inc(i);inc(j); inc(k); end; inc(k);inc(k); while (c[k]=0)and(k>1) do dec(k); l3:=k; end; procedure print(c:arr1); var i:int; begin for i:=l3 downto 1 do write(c[i]); end; begin s:=''; while not eoln do begin read(aa); s:=s+aa; end; l1:=length(s); for i:=l1 downto 1 do val(s[i],a[l1+1-i]); s:=''; readln; while not eoln do begin read(aa); s:=s+aa; end; l2:=length(s); for i:=l2 downto 1 do val(s[i],b[l2+1-i]); add(a,b,c); print(c); end.
高精度加法
最新推荐文章于 2019-10-20 13:10:03 发布