Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project2;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- function plus(s, s1: string): string;
- var
- s2: string;
- i, x, y, c, bon: integer;
- begin
- if length(s) < length(s1) then
- begin
- s2 := s;
- s := s1;
- s1 := s2
- end;
- bon := 0;
- for i := length(s) downto (length(s) - length(s1) + 1) do
- begin
- x := strtoint(s[i]);
- y := strtoint(s1[length(s1) -(length(s) - i)]);
- c := x + y + bon;
- bon := c div 10;
- c := c mod 10;
- s2 := inttostr(c);
- s[i] := s2[1];
- end;
- i := (length(s) - length(s1));
- while (i >= 1) and (bon > 0) do
- begin
- x := strtoint(s[i]);
- c := x + bon;
- bon := c div 10;
- c := c mod 10;
- s2 := inttostr(c);
- s[i] := s2[1];
- dec(i);
- end;
- if (bon > 0) then
- begin
- s2 := inttostr(bon);
- s := s2 + s;
- end;
- plus := s;
- end;
- var
- s, s1, s2, sist, sum: string;
- i, j, x, ost, ch, k, time: integer;
- begin
- readln(s);
- readln(s1);
- if (s = '0') or (s1 = '0') then
- begin
- writeln('0');
- halt;
- end;
- sum := '0';
- if length(s) < length(s1) then
- begin
- s2 := s1;
- s1 := s;
- s := s2;
- end;
- sist := s;
- time := 0;
- for j := length(s1) downto 1 do
- begin
- s := sist;
- ch := strtoint(s1[j]);
- ost := 0;
- for i := length(s) downto 1 do
- begin
- x := strtoint(s[i]) * ch + ost;
- ost := x div 10;
- s2 := inttostr(x mod 10);
- s[i] := s2[1];
- end;
- if ost > 0 then
- s := inttostr(ost) + s;
- for k := 1 to time do
- s := s + '0';
- sum := plus(sum , s);
- inc(time);
- end;
- writeln(sum);
- readln;readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement