代码一:
program gaojingjia;
const max=200;
var
sa,sb:string;
b:array[1..max] of integer;
a:array[1..max+1] of integer;
len,la,lb, i:integer;
begin
readln(sa); readln(sb);
fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0);
la:=length(sa); lb:=length(sb);
for i:= la downto 1 do a[la-i+1]:=ord(sa[i])-ord('0');
for i:= lb downto 1 do b[lb-i+1]:=ord(sb[i])-ord('0');
if la>lb then len:=la else len:=lb;
for i:=1 to len do
begin
a[i+1]:=a[i+1]+(a[i]+b[i]) div 10;
a[i]:=(a[i]+b[i]) mod 10;
end;
if a[len+1]>0 then len:=len+1;
for i:=len downto 1 do write(a[i]);
writeln
end.
代码二:const
size= 200+1;
type
hugeint = Record
len : Integer;
num : Array[1..size] Of Integer;
End;
var a,b:hugeint;
s1,s2:string;
i:integer;
procedure add(a, b : hugeint);
Var
i : Integer;
ans : hugeint;
begin
FillChar(ans.num, SizeOf(ans.num), 0);
If a.len > b.len
then ans.len := a.len
else ans.len := b.len;
for i := 1 To ans.len Do
begin
ans.num[i] :=ans.num[i]+a.num[i]+b.num[i];
ans.num[i + 1] := ans.num[i + 1] + ans.num[i] div 10;
ans.num[i] := ans.num[i] mod 10;
end;
If ans.num[ans.len + 1] > 0
Then Inc(ans.len);
for i:=ans.len downto 1 do write(ans.num[i]);
writeln;
end;
procedure datain;
begin
//assign(input,'highplus.in'); assign(output,'highplus.out');
//reset(input); rewrite(output);
readln(s1);
readln(s2);
a.len:=length(s1);
b.len:=length(s2);
for i:=1 to a.len do a.num[i]:=ord(s1[a.len-i+1])-ord('0');
for i:=1 to b.len do b.num[i]:=ord(s2[b.len-i+1])-ord('0');
end;
begin
datain;
add(a,b);
//close(input);close(output);
end.