Предмет:
Тип роботи:
Курсова робота
К-сть сторінок:
36
Мова:
Українська
style="text-align: justify;">procedure output;
var i, j : integer;
begin
for i:=1 to 5 do begin
writeln;
for j:=1 to 25 do
write(mas[i,j]);
end;
end;
procedure table_out;
begin
writeln;
writeln(' Rishennya zadachi');
writeln('|------------------------------------------------|');
writeln('|house | nation | color | drink | cigar | animal |');
write('| 1 |');
if mas[1,1]=1 then write('angl ');
if mas[1,2]=1 then write('esp ');
if mas[1,3]=1 then write('jap ');
if mas[1,4]=1 then write('norv ');
if mas[1,5]=1 then write('ukr ');
if mas[1,6]=1 then write('red ');
if mas[1,7]=1 then write('blue ');
if mas[1,8]=1 then write('beg ');
if mas[1,9]=1 then write('yel ');
if mas[1,10]=1 then write('green ');
if mas[1,11]=1 then write('tea ');
if mas[1,12]=1 then write('coffe ');
if mas[1,13]=1 then write('milk ');
if mas[1,14]=1 then write('water ');
if mas[1,15]=1 then write('juice ');
if mas[1,16]=1 then write('Old ');
if mas[1,17]=1 then write('Cool ');
if mas[1,18]=1 then write('Old ');
if mas[1,19]=1 then write('Lucki ');
if mas[1,20]=1 then write('Parl ');
if mas[1,21]=1 then write('horse ');
if mas[1,22]=1 then write('fox ');
if mas[1,23]=1 then write('dog ');
if mas[1,24]=1 then write('zebra ');
if mas[1,25]=1 then write('ravl ');
writeln;
write('| 2 |');
if mas[2,1]=1 then write('angl ');
if mas[2,2]=1 then write('esp ');
if mas[2,3]=1 then write('jap ');
if mas[2,4]=1 then write('norv ');
if mas[2,5]=1 then write('ukr ');
if mas[2,6]=1 then write('red ');
if mas[2,7]=1 then write('blue ');
if mas[2,8]=1 then write('white ');
if mas[2,9]=1 then write('yel ');
if mas[2,10]=1 then write('green ');
if mas[3,11]=1 then write('tea ');
if mas[3,12]=1 then write('coffe ');
if mas[3,13]=1 then write('milk ');
if mas[3,14]=1 then write('water ');
if mas[3,15]=1 then write('juice ');
if mas[2,16]=1 then write('Old ');
if mas[2,17]=1 then write('Cool ');
if mas[2,18]=1 then write('Chest ');
if mas[2,19]=1 then write('Lucki ');
if mas[2,20]=1 then write('Parl ');
if mas[2,21]=1 then write('horse ');
if mas[2,22]=1 then write('fox ');
if mas[2,23]=1 then write('dog ');
if mas[2,24]=1 then write('zebra ');
if mas[2,25]=1 then write('ravl ');
writeln;
write('| 3 |');
if mas[3,1]=1 then write('angl ');
if mas[3,2]=1 then write('esp ');
if mas[3,3]=1 then write('jap ');
if mas[3,4]=1 then write('norv ');
if mas[3,5]=1 then write('ukr ');
if mas[3,6]=1 then write('red ');
if mas[3,7]=1 then write('blue ');
if mas[3,8]=1 then write('white ');
if mas[3,9]=1 then write('yel ');
if mas[3,10]=1 then write('green ');
if mas[3,11]=1 then write('tea ');
if mas[3,12]=1 then write('coffe ');
if mas[3,13]=1 then write('milk ');
if mas[3,14]=1 then write('water ');
if mas[3,15]=1 then write('juice ');
if mas[3,16]=1 then write('Old ');
if mas[3,17]=1 then write('Cool ');
if mas[3,18]=1 then write('Chest ');
if mas[3,19]=1 then write('Lucki ');
if mas[3,20]=1 then write('Parl ');
if mas[3,21]=1 then write('horse ');
if mas[3,22]=1 then write('fox ');
if mas[3,23]=1 then write('dog ');
if mas[3,24]=1 then write('zebra ');
if mas[3,25]=1 then write('ravl ');
writeln;
write('| 4 |');
if mas[4,1]=1 then write('angl ');
if mas[4,2]=1 then write('esp ');
if mas[4,3]=1 then write('jap ');
if mas[4,4]=1 then write('norv ');
if mas[4,5]=1 then write('ukr ');
if mas[4,6]=1 then write('red ');
if mas[4,7]=1 then write('blue ');
if mas[4,8]=1 then write('white ');
if mas[4,9]=1 then write('yel ');
if mas[4,10]=1 then write('green ');
if mas[4,11]=1 then write('tea ');
if mas[4,12]=1 then write('coffe ');
if mas[4,13]=1 then write('milk ');
if mas[4,14]=1 then write('water ');
if mas[4,15]=1 then write('juice ');
if mas[4,16]=1 then write('Old ');
if mas[4,17]=1 then write('Cool ');
if mas[4,18]=1 then write('Chest ');
if mas[4,19]=1 then write('Lucki ');
if mas[4,20]=1 then write('Parl ');
if mas[4,21]=1 then write('horse ');
if mas[4,22]=1 then write('fox ');
if mas[4,23]=1 then write('dog ');
if mas[4,24]=1 then write('zebra ');
if mas[4,25]=1 then write('ravl ');
writeln;
write('| 5 |');
if mas[5,1]=1 then write('angl ');
if mas[5,2]=1 then write('esp ');
if mas[5,3]=1 then write('jap ');
if mas[5,4]=1 then write('norv ');
if mas[5,5]=1 then write('ukr ');
if mas[5,6]=1 then write('red ');
if mas[5,7]=1 then write('blue ');
if mas[5,8]=1 then write('white ');
if mas[5,9]=1 then write('yel ');
if mas[5,10]=1 then write('green ');
if mas[5,11]=1 then write('tea ');
if mas[5,12]=1 then write('coffe ');
if mas[5,13]=1 then write('milk ');
if mas[5,14]=1 then write('water ');
if mas[5,15]=1 then write('juice ');
if mas[5,16]=1 then write('Old ');
if mas[5,17]=1 then write('Cool ');
if mas[5,18]=1 then write('Chest ');
if mas[5,19]=1 then write('Lucki ');
if mas[5,20]=1 then write('Parl ');
if mas[5,21]=1 then write('horse ');
if mas[5,22]=1 then write('fox ');
if mas[5,23]=1 then write('dog ');
if mas[5,24]=1 then write('zebra ');
if mas[5,25]=1 then write('ravl ');
end;
procedure perestanovka (fl : integer);
var i, s : integer;
var l1, l2 : integer;
begin
if (k1<>k2) then begin
l1:=k1+5*fl;
l2:=k2+5*fl;
for i := 1 To 5 Do
begin
s:=mas [i,l1];
mas [i,l1] := mas[i,l2];
mas [i,l2] := s;
end;
end;
k2:=k2+1;
if (k2=6) then
begin
k1:=k1+1;
k2:=1;
end;
end;
function Rule01 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,1]=1) and (mas[i,6]=1) then
Rule01:=1
else
Rule01:=0;
end;
function Rule02 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,2]=1) and (mas[i,23]=1) then
Rule02:=1
else
Rule02:=0;
end;
function Rule03 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,5]=1) and (mas[i,11]=1) then
Rule03:=1
else
Rule03:=0;
end;
function Rule04 : integer;
var i: integer;
begin
for i:=2 to 5 do
if (mas [i,10]=1)and (mas[i-1,8]=1) then
Rule04:=1
else
Rule04:=0;
end;
function Rule05 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,10]=1) and (mas[i,12]=1) then
Rule05:=1
else
Rule05:=0;
end;
function Rule06 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,16]=1) and (mas[i,25]=1) then
Rule06:=1
else
Rule06:=0;
end;
function Rule07 : integer;
begin
if mas [3,13]=1 then
Rule07:=1
else
Rule07:=0;
end;
function Rule08 : integer;
begin
if (mas[1,4]=1) then
Rule08:=1
else Rule08:=0;
end;
function Rule09 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,17]=1) and (mas[i,9]=1) then
Rule09:=1
else
Rule09:=0;
end;
function Rule10 : integer;
var i: integer;
begin
for i:=2 to 4 do
if ((mas [i,18]=1) and (mas[i-1,22]=1)) or ((mas [i,18]=1) and (mas[i+1,22]=1)) then
Rule10:=1
else
Rule10:=0;
end;
function Rule11 : integer;
var i: integer;
begin
for i:=2 to 4 do
if ((mas [i,21]=1) and (mas[i-1,16]=1)) or ((mas [i,21]=1) and (mas[i+1,16]=1)) then
Rule11:=1
else
Rule11:=0;
end;
function Rule12 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,20]=1) and (mas[i,3]=1) then
Rule12:=1
else
Rule12:=0;
end;
function Rule13 : integer;
var i: integer;
begin
for i:=2 to 4 do
if ((mas [i,4]=1) and (mas[i-1,7]=1)) or ((mas [i,4]=1) and (mas[i+1,7]=1)) then
Rule13:=1
else
Rule13:=0;
end;
function Rule14 : integer;
var i: integer;
begin
for i:=1 to 5 do
if (mas [i,24]=1) and (mas[i,19]=1) then
Rule14:=1
else
Rule14:=0;
end;
function Rule15 : integer;
var i: integer;
begin
for i:=2 to 4 do
if ((mas [i,4]=1) and (mas[i-1,7]=1)) or ((mas [i,4]=1) and (mas[i+1,7]=1)) then
Rule15:=1
else
Rule15:=0;
end;
begin
for i:=1 to 5 do begin
for j:= 1 to 5 do begin
if i = j then begin
mas[i,j]:= 1;
mas[i,j+5]:=1;
mas[i,j+10]:=1;
mas[i,j+15]:=1;
mas[i,j+20]:=1;
end
else
begin
mas[i,j]:= 0;
mas[i,j+5]:=0;
mas[i,j+10]:=0;
mas[i,j+15]:=0;
mas[i,j+20]:=0;
end;
end;
end;
k1:=1;
k2:=1;
flag1:=0;
while (flag1=0) and (k1<6) and (k2<6) do begin
perestanovka(0);
if Rule08=0 then continue;
k1:=1;
k2:=1;
flag2:=0;
while (flag2=0) and (k1<6) and (k2<6) do begin
perestanovka(1);
if (Rule04=0) or (Rule01=0) or (Rule13=0) then
continue;
k1:=1;
k2:=1;
flag3:=0;
while (flag3=0) and (k1<6) and (k2<6) do begin
perestanovka(2);
if (Rule07=0) or (Rule03=0) or (Rule05=0) then
continue;
k1:=1;
k2:=1;
flag4:=0;
while (flag4=0) and (k1<6) and (k2<6) do begin
perestanovka(3);
if (Rule09=0) or (Rule14=0) or (Rule12=0) or (Rule15=0) then
continue;
k1:=1;
k2:=1;
flag5:=0;
while (flag5=0) and (k1<6) and (k2<6) do begin
perestanovka(4);
if (Rule02=0) or (Rule06=0) or (Rule10=0) or (Rule11=0) then
continue
else begin
flag1:=1;
flag2:=1;
flag3:=1;
flag4:=1;
flag5:=1
end;
end;
end;
end;
end;
end;
table_out;
readln;
end.