Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure AddString(var s: string; a: string);
- var
- i, t, o: Integer;
- n: Boolean;
- m: string;
- begin
- if Length(s) < Length(a) then
- exit;
- n := false;
- o := Length(s) - Length(a);
- for i := Length(a) downto 1 do
- begin
- t := StrToIntDef(Copy(s, i + o, 1), 0);
- t := t + StrToIntDef(Copy(a, i, 1), 0);
- if n then
- begin
- t := t + 1;
- n := false;
- end;
- if t >= 10 then
- begin
- n := true;
- t := t mod 10;
- end;
- m := IntToStr(t);
- s[i + o] := m[1];
- end;
- if n and (o > 0) then
- begin
- t := StrToIntDef(Copy(s, 1, o), 0);
- t := t + 1;
- m := IntToStr(t);
- if Length(m) > o then
- begin
- s := '0' + s;
- o := o + 1;
- end;
- for i := 1 to o do
- s[i] := m[i];
- end
- else if n then
- s := '1' + s;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement