Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program projekt15;
- uses crt;
- var t: array [1..4,1..4] of byte;
- i,j:byte;
- procedure generuj;
- var i,j:byte;
- begin;
- for i:=1 to 4 do
- begin;
- for j:=1 to 4 do
- t[i,j]:=16-(4*(i-1)+j);
- end;
- t[4,4]:=16;
- end;
- procedure wyswietl;
- var i,j:byte;
- begin;
- for i:=1 to 4 do
- begin;
- for j:=1 to 4 do
- if t[i,j]<10 then write(' ',t[i,j],' ')
- else
- if t[i,j]=16 then write(' ') else write( t[i,j], ' ');
- writeln(' ');
- end;
- end;
- procedure miejsce;
- var i,j,a,f,x,y,c:byte;
- begin;
- write('Podaj liczbe ');
- read(a);
- for i:=1 to 4 do
- begin;
- for j:=1 to 4 do
- if a=t[i,j] then
- begin;
- x:=j;
- y:=i;
- end;
- end;
- writeln('Wsp˘rz©dna x to: ',x);
- writeln('Wsp˘rz©dna y to: ',y);
- f:=0;
- if t[y,x-1]=16 then
- begin
- f:=1;
- t[y,x-1]:=a;
- t[y,x]:=16;
- end;
- if t[y-1,x]=16 then
- begin
- f:=1;
- t[y-1,x]:=a;
- t[y,x]:=16;
- end;
- if t[y,x+1]=16 then
- begin
- f:=1;
- t[y,x+1]:=a;
- t[y,x]:=16;
- end;
- if t[y+1,x]=16 then
- begin
- f:=1;
- t[y+1,x]:=a;
- t[y,x]:=16;
- end;
- if f=1 then writeln('Moľna przesunĄ† klocek')
- else writeln('Nie moľna przesunĄ† klocka');
- end;
- function przesun (a:byte):byte;
- var x,y
- begin;
- clrscr;
- generuj;
- wyswietl;
- miejsce;
- wyswietl;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement