-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path103.pas
More file actions
82 lines (70 loc) · 1.49 KB
/
Copy path103.pas
File metadata and controls
82 lines (70 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var
a,b,r: array[1..1000] of byte;
la,lb,lc,i,mem,tm: integer;
c: char;
f: text;
begin
assign(f,'input.txt');
reset(f);
i:=0;
repeat
read(f,c);
if (c in ['0'..'9']) then
begin
la:=la+1;
a[la]:=ord(c)-48;
end;
until not(c in ['0'..'9']);
repeat read(f,c); until (c in ['0'..'9'])or(eof(f));
lb:=1;
b[lb]:=ord(c)-48;
repeat
read(f,c);
if (c in ['0'..'9']) then
begin
lb:=lb+1;
b[lb]:=ord(c)-48;
end;
until not(c in ['0'..'9'])or(eof(f));
close(f);
la:=la+1;
lb:=lb+1;
for i:=1 to la div 2 do begin
mem:=a[i];
a[i]:=a[la-i];
a[la-i]:=mem;
end;
for i:=1 to lb div 2 do begin
mem:=b[i];
b[i]:=b[lb-i];
b[lb-i]:=mem;
end;
la:=la-1;
lb:=lb-1;
mem:=0;
if la>lb then tm:=la else tm:=lb;
for i:=1 to tm do
begin
r[i]:=a[i]+b[i]+mem;
mem:=0;
if r[i]>9 then begin
r[i]:=r[i]-10;
mem:=1;
end;
end;
if mem=1 then begin
tm:=tm+1;
r[tm]:=1;
end;
tm:=tm+1;
for i:=1 to tm div 2 do begin
mem:=r[i];
r[i]:=r[tm-i];
r[tm-i]:=mem;
end;
tm:=tm-1;
assign(f,'output.txt');
rewrite(f);
for i:=1 to tm do write(f,r[i]);
close(f);
end.