fork download
  1. // Minesweeper отварање
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int bombe[10][10] = {0};
  7. bool otvoreno[10][10] = {false};
  8.  
  9. void DFS(int i, int j)
  10. {
  11. if (i < 0 or i == 10 or j < 0 or j == 10 or otvoreno[i][j])
  12. return;
  13. otvoreno[i][j] = true;
  14. if (bombe[i][j] == 0)
  15. {
  16. for (int x = -1; x <= 1; x++)
  17. for (int y = -1; y <= 1; y++)
  18. {
  19. if (x == 0 and y == 0)
  20. continue;
  21. DFS(i + x, j + y);
  22. }
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. int polje[10][10];
  29. for (int i = 0; i < 10; i++)
  30. {
  31. string ulaz;
  32. cin >> ulaz;
  33. for (int j = 0; j < 10; j++)
  34. polje[i][j] = ulaz[j] - '0';
  35. }
  36. int red, kolona;
  37. cin >> red >> kolona;
  38. for (int i = 0; i < 10; i++)
  39. for (int j = 0; j < 10; j++)
  40. for (int x = -1; x <= 1; x++)
  41. for (int y = -1; y <= 1; y++)
  42. {
  43. if (x == 0 and y == 0)
  44. continue;
  45. if (i + x >= 0 and i + x < 10 and j + y >= 0 and j + y < 10)
  46. bombe[i][j] += polje[i + x][j + y];
  47. }
  48. DFS(red, kolona);
  49. if (polje[red][kolona] == 1)
  50. cout << "boom" << endl;
  51. else
  52. for (int i = 0; i < 10; i++)
  53. {
  54. for (int j = 0; j < 10; j++)
  55. if (!otvoreno[i][j])
  56. cout << "x";
  57. else
  58. if (bombe[i][j] == 0)
  59. cout << ".";
  60. else
  61. cout << bombe[i][j];
  62. cout << endl;
  63. }
  64. return 0;
  65. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
-144xxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx