Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. program projekt15;
  2. uses crt;
  3. var t: array [1..4,1..4] of byte;
  4. i,j:byte;
  5. procedure generuj;
  6. var i,j:byte;
  7. begin;
  8. for i:=1 to 4 do
  9. begin;
  10. for j:=1 to 4 do
  11. t[i,j]:=16-(4*(i-1)+j);
  12. end;
  13. t[4,4]:=16;
  14. end;
  15. procedure wyswietl;
  16. var i,j:byte;
  17. begin;
  18. for i:=1 to 4 do
  19. begin;
  20. for j:=1 to 4 do
  21. if t[i,j]<10 then write(' ',t[i,j],' ')
  22. else
  23. if t[i,j]=16 then write(' ') else write( t[i,j], ' ');
  24. writeln(' ');
  25. end;
  26. end;
  27. procedure miejsce;
  28. var i,j,a,f,x,y,c:byte;
  29. begin;
  30. write('Podaj liczbe ');
  31. read(a);
  32. for i:=1 to 4 do
  33. begin;
  34. for j:=1 to 4 do
  35. if a=t[i,j] then
  36. begin;
  37. x:=j;
  38. y:=i;
  39. end;
  40. end;
  41.  
  42. writeln('Wsp˘rz©dna x to: ',x);
  43. writeln('Wsp˘ˆrz©dna y to: ',y);
  44.  
  45. f:=0;
  46. if t[y,x-1]=16 then
  47. begin
  48. f:=1;
  49. t[y,x-1]:=a;
  50. t[y,x]:=16;
  51. end;
  52. if t[y-1,x]=16 then
  53. begin
  54. f:=1;
  55. t[y-1,x]:=a;
  56. t[y,x]:=16;
  57. end;
  58. if t[y,x+1]=16 then
  59. begin
  60. f:=1;
  61. t[y,x+1]:=a;
  62. t[y,x]:=16;
  63. end;
  64. if t[y+1,x]=16 then
  65. begin
  66. f:=1;
  67. t[y+1,x]:=a;
  68. t[y,x]:=16;
  69. end;
  70. if f=1 then writeln('Moľna przesunĄ† klocek')
  71. else writeln('Nie moľna przesunĄ† klocka');
  72. end;
  73. function przesun (a:byte):byte;
  74. var x,y
  75.  
  76.  
  77.  
  78. begin;
  79. clrscr;
  80. generuj;
  81. wyswietl;
  82. miejsce;
  83. wyswietl;
  84.  
  85. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement