Advertisement
MoonDeMon

Minesweeper

Jan 20th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. program minesweeper;
  2.  
  3. var
  4. x:array[1..100,1..100] of char;
  5. counter,rng,i,j,m,n,p,q,r,s:integer;
  6.  
  7. begin
  8. write('rows: ');
  9. read(m);
  10. write('columns: ');
  11. read(n);
  12.  
  13. (*baris*)
  14. for i:=1 to m do
  15. begin
  16. (*kolom*)
  17. for j:=1 to n do
  18. begin
  19. (*random*)
  20. rng:=random(2);
  21. if rng=1 then
  22. begin
  23. x[i,j]:='*';
  24. end
  25. else
  26. begin
  27. x[i,j]:='0';
  28. end;
  29. end;
  30. writeln;
  31. end;
  32.  
  33. (*cek angka*)
  34. for i:=1 to m do
  35. begin
  36. for j:=1 to n do
  37. begin
  38. if (x[i,j]='0') then
  39. begin
  40. counter:=0;
  41. for p:=1 to 3 do
  42. begin
  43. for q:=1 to 3 do
  44. begin
  45. if (x[i+2-p,j+2-q]='*') then
  46. counter:=counter+1;
  47.  
  48. end;
  49. end;
  50. case counter of
  51. 0:x[i,j]:='0';
  52. 1:x[i,j]:='1';
  53. 2:x[i,j]:='2';
  54. 3:x[i,j]:='3';
  55. 4:x[i,j]:='4';
  56. 5:x[i,j]:='5';
  57. 6:x[i,j]:='6';
  58. 7:x[i,j]:='7';
  59. 8:x[i,j]:='8';
  60. end;
  61. end;
  62. end;
  63. end;
  64.  
  65. (*view jawaban*)
  66. for i:=1 to 3 do
  67. begin
  68. for j:=1 to n do
  69. begin
  70. write(x[i,j]);
  71. end;
  72. writeln;
  73. end;
  74.  
  75. readln;
  76. readln;
  77. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement