Cod sursa(job #885142)

Utilizator DjokValeriu Motroi Djok Data 21 februarie 2013 17:47:16
Problema A+B Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.13 kb
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.