Pagini recente » Cod sursa (job #487688) | Cod sursa (job #892741) | Cod sursa (job #495330) | Cod sursa (job #243985) | Cod sursa (job #885145)
Cod sursa(job #885145)
Program Trolling;
var fi,fo:text;
s,s1:string;
i,x,code,m:integer;
a:array[1..100] of integer;
b:array[1..100] of integer;
c:array[1..100] of integer;
begin
assign(fi, 'adunare.in');
reset(fi);
assign(fo,'adunare.out');
rewrite(fo);
readln(fi, s);
readln(fi, s1);
For i:=1 to length(s) do
begin
val(s[i],x,code);
a[length(s)-i+1]:=x;
end;
For i:=1 to length(s1) do
begin
val(s1[i],x,code);
b[length(s1)-i+1]:=x;
end;
If length(s)>=length(s1) then m:=length(s)
else m:=length(s1);
For i:=1 to m do begin
c[i]:=a[i]+b[i];
end;
For i:=1 to m do
begin
c[i+1]:=(c[i] div 10)+c[i+1];
c[i]:=c[i] mod 10;
end;
If c[m+1]<>0 then
For i:=m+1 downto 1 do
write(fo, c[i])
else
For i:=m downto 1 do
write(fo, c[i]);
close(fi);
close(fo);
end.