-
Notifications
You must be signed in to change notification settings - Fork 0
/
DMAS.PAS
68 lines (58 loc) · 1.92 KB
/
DMAS.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
program didelis_masyvas;
{gaunasi 715x715 boolean masyvas, cia jau atrodo riba}
type Tmas = array [1 .. 715, 0 .. 4] of set of 0 .. 142;
var mas : Tmas;
procedure valyk (mas : Tmas);
var ck, ck1 : word;
begin
for ck := 1 to 715 do
for ck1 := 0 to 4 do
mas [ck, ck1] := [];
end;
{jei elementas masyve - jis atitinka true reiksme ir atv}
function tiesa (x, Y : integer) : boolean;
var ind, elem : integer;
begin
ind := y div 143;
elem := y mod 143;
if ind = 5 then ind := 0;
if elem in mas [x, ind] then tiesa := true
else tiesa := false
end;
procedure itrauk (x, Y : integer; var mas : Tmas);
var ind, elem : integer;
begin
ind := y div 143;
elem := y mod 143;
if ind = 5 then ind := 0;
mas [x, ind] := mas [x, ind] + [elem];
end;
procedure istrauk (x, Y : integer; var mas : Tmas);
var ind, elem : integer;
begin
ind := y div 143;
elem := y mod 143;
if ind = 5 then ind := 0;
mas [x, ind] := mas [x, ind] - [elem];
end;
begin
valyk (mas);
{tarkim reikia suzymeti matricos MAS taskus (1,1),(715,1),(1,715),(715,715)}
itrauk ( 1, 1, mas);
itrauk (715, 715, mas);
itrauk ( 1, 715, mas);
itrauk (715, 1, mas);
if tiesa (715, 715) then writeln ('tiesa') else writeln ('netiesa');
if tiesa ( 1, 1) then writeln ('tiesa') else writeln ('netiesa');
if tiesa (715, 1) then writeln ('tiesa') else writeln ('netiesa');
if tiesa ( 1, 715) then writeln ('tiesa') else writeln ('netiesa');
istrauk (715, 715, mas);
istrauk ( 1, 715, mas);
istrauk (715, 1, mas);
istrauk ( 1, 1, mas);
if tiesa (715, 715) then writeln ('tiesa') else writeln ('netiesa');
if tiesa ( 1, 1) then writeln ('tiesa') else writeln ('netiesa');
if tiesa (715, 1) then writeln ('tiesa') else writeln ('netiesa');
if tiesa ( 1, 715) then writeln ('tiesa') else writeln ('netiesa');
writeln;
end.