From 7d19f480637e9e880b98dabfbcf8e885b0a2d3b9 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Tue, 21 Feb 2017 21:09:39 +0700 Subject: Update others/volume1 --- others/volume1/096.pas | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 others/volume1/096.pas (limited to 'others/volume1/096.pas') diff --git a/others/volume1/096.pas b/others/volume1/096.pas new file mode 100644 index 0000000..4cb877c --- /dev/null +++ b/others/volume1/096.pas @@ -0,0 +1,34 @@ +uses math, strutils; + +var + a, b: ansistring; + n: int16; + remain: boolean = false; + d: uint8; + +begin + readln(a); + readln(b); + n := max(length(a), length(b)) + 1; + a := addchar('0', a, n); + b := addchar('0', b, n); + repeat + if remain then + d := ord(a[n]) + ord(b[n]) - 47 + else + d := ord(a[n]) + ord(b[n]) - 48; + if d > 57 then + begin + dec(d, 10); + remain := true + end + else + remain := false; + a[n] := chr(d); + dec(n) + until n = 0; + if ord(a[1]) = 48 then + writeln(copy(a, 2, length(a) - 1)) + else + writeln(a) +end. -- cgit 1.4.1