Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4. #include <windows.h>
  5. #include <time.h>
  6. #define SIZE 12
  7.  
  8. char board[SIZE][SIZE];
  9. char game_board[SIZE][SIZE];
  10. void budowanie_planszy()
  11. {
  12. int i, j;
  13.  
  14. for(i = 0; i < SIZE; i++) //Wypelnianie calej planszy "-"
  15. for(j = 0; j < SIZE; j++)
  16. board[i][j] = '-';
  17.  
  18. srand(time(0));
  19. for(j = 0; j < SIZE; j++){ //Wypelniaie losowych pol "*" (losowanie min)
  20. int random = rand() % (SIZE - 1) + 1;
  21. board[random][j] = '*';
  22. }
  23.  
  24. for(i = 0; i < SIZE; i++) //Sprawdzanie czy pierwszy i ostani rzad i kolumna sa puste
  25. for(j = 0; j < SIZE; j++)
  26. if(i == 0 || i == SIZE - 1)
  27. board[i][j] = ' ';
  28.  
  29. for(j = 0; j < SIZE; j++)
  30. for(i = 0; i < SIZE; i++)
  31. if(j == 0 || j == SIZE - 1)
  32. board[i][j] = ' ';
  33. }
  34. drukowanie_planszy()
  35. {
  36. int i, j;
  37.  
  38. printf(" "); //Wypisanie liczby rzedu
  39. for(i = 1; i < SIZE - 1; i++)
  40. printf("%d ", i);
  41. printf("\n");
  42.  
  43. for(i = 0; i < SIZE; i++){ //Wypisanie liczby kolumn
  44. for(j = 0; j < SIZE; j++)
  45. printf("%c ", board[i][j]);
  46. if(i > 0 && i < SIZE - 1)
  47. printf("%d", i);
  48. printf("\n");
  49. }
  50. }
  51. void ekran_startowy()
  52. {
  53. puts("------------------------------------------------------------------");
  54. puts("-----------------------Witaj w Saperze!---------------------------");
  55. puts("--------------------------PP2_projekt-----------------------------");
  56. puts("------------------------1 Kamien milowy---------------------------");
  57. puts("------------------------------------------------------------------");
  58. puts("\n\n");
  59. }
  60. void zakryta_plansza()
  61. {
  62.  
  63. int i, j;
  64. int wiersz, kolumna;
  65. printf("Tworzenie planszy....\n\n");
  66. Sleep(1000);
  67. for(i = 0; i < SIZE; i++)//Zakrywanie planszy
  68. for(j = 0; j < SIZE; j++)
  69. game_board[i][j] = 'o';
  70.  
  71. for(kolumna = 0; kolumna < SIZE-2; kolumna++)//Wyswietlanie planszy zakrytej
  72. printf("%d ", kolumna + 1);
  73.  
  74. printf("\n\n");
  75.  
  76. for(wiersz = 0; wiersz < SIZE-2; wiersz++)
  77. {
  78. for(kolumna = 0; kolumna < SIZE-2; kolumna++)
  79. {
  80. printf("%c ", game_board[wiersz][kolumna]);
  81. }
  82. printf(" %d ", wiersz + 1);
  83. printf("\n");
  84. }
  85. }
  86. void start()
  87. {
  88. system("cls");
  89. //funkcje budujace plansze
  90. budowanie_planszy();
  91. drukowanie_planszy();
  92. zakryta_plansza();
  93. }
  94. int main()
  95. {
  96. ekran_startowy();
  97. system("pause"); //Wstrzymuje prace programy i czeka na wcisniecie klawisza
  98. start();
  99.  
  100.  
  101. return 0;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement