Advertisement
savrasov

Untitled

Nov 25th, 2016
3,318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uses
  2.   SysUtils;
  3.  
  4. var
  5.   s, s1: string;
  6.  
  7. function pls(s, s1: string): string;
  8. var
  9.   i, len, c: integer;
  10.   f: string;
  11. begin
  12.   if (length(s) > length(s1)) then len := length(s)
  13.   else len := length(s1);
  14.   c := 0;
  15.   for i := length(s) to len do s := '0' + s;
  16.   for i := length(s1) to len do s1 := '0' + s1;
  17.   for i := len + 1 downto 1 do
  18.   begin
  19.     c := strtoint(s[i]) + strtoint(s1[i]) + c;
  20.     f := inttostr(c mod 10) + f;
  21.     c := c div 10;
  22.   end;
  23.   while (f[1] = '0') do delete(f, 1, 1);
  24.   pls := f;
  25. end;
  26.  
  27. begin
  28.   readln(s);
  29.   readln(s1);
  30.   writeln(pls(s, s1));
  31. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement