-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPASKALIS.PAS
108 lines (98 loc) · 1.86 KB
/
PASKALIS.PAS
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
program paskalis;
const
n = 34;
type
Telem = array [1 .. 100] of 0 .. 9;
Teil = array [1 .. n] of ^Telem;
var
eil1, eil2 : Teil;
ck, ckn, ckf : longint;
f : text;
procedure rasyk (var eil : Teil; var f : text);
var
ckn : 1 .. 100;
ck : byte;
t : boolean;
begin
for ckn := 1 to n do
begin
for ck := 99 to 1 do
if (eil [ckn]^[ck] <> 0) and not t then
begin
t := true;
write (f, eil [ckn]^[ck]);
end;
write (f, ' ');
end;
writeln (f)
end;
function teig (elem : Telem) : boolean;
var
ck : byte;
t : boolean;
begin
t := true;
for ck := 1 to 100 do
if elem [ck] = 0 then t := false;
teig := t
end;
procedure sukurk (var eil1, eil2 : Teil);
var
ck : word;
ckn : byte;
begin
for ck := 1 to n do
begin
new (eil1 [ck]);
new (eil2 [ck]);
for ckn := 1 to 100 do
begin
eil1 [ck]^ [ckn] := 0;
eil2 [ck]^ [ckn] := 0;
end;
end;
eil1 [1]^ [1] := 1;
end;
procedure valyk (var eil1, eil2 : Teil);
var
ck : byte;
begin
for ck := 1 to n do
begin
dispose (eil1 [ck]);
dispose (eil2 [ck]);
end
end;
procedure sum (var eil1, eil2 : Teil; n : integer);
var
ckn : byte;
ck : byte;
s : 0 .. 18;
begin
for ckn := 1 to n do
begin
for ck := 99 downto 1 do
begin
s := eil1 [ckn]^[ck] + eil1 [ckn - 1]^[ck];
eil1 [ckn]^ := eil2 [ck]^;
eil2 [ckn]^ := s mod 10;
eil2 [ck + 1]^ := eil2 [ck + 1] + s div 10;
end;
end;
end;
begin
assign (f, 'Paskalis.txt');
rewrite (f);
sukurk (eil1, eil2);
for ckn := 1 to n do
begin
{ sumuoju }
for ck := 1 to ckn do
sum (eil1 [ck]^, eil2 [ck]^, ckn);
{ skiaciuoju }
for ckf := 100 to 1 do
if teig (eil2 [ck]^) then rasyk (eil2, f);
end;
close (f);
valyk (eil1, eil2);
end.