fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, mat[4][4];
  6. cin >> n;
  7. for (int i = 1; i <= n; ++i) {
  8. for (int j = 1; j <= n; ++j) {
  9. cin >> mat[i][j];
  10. }
  11. }
  12. int win = 0;
  13. for (int i = 1; i <= n; ++i) {
  14. if (mat[i][1] == mat[i][2] && mat[i][2] == mat[i][3]) {
  15. if (mat[i][1] == 1) {
  16. win = 1;
  17. cout << "jucatorul X";
  18. break;
  19. } else if (mat[i][1] == 0) {
  20. win = 1;
  21. cout << "jucatorul 0";
  22. break;
  23. }
  24. }
  25. if (mat[1][1] == mat[2][1] && mat[2][1] == mat[3][1]) {
  26. if (mat[i][1] == 1) {
  27. win = 1;
  28. cout << "jucatorul X";
  29. break;
  30. } else if (mat[i][1] == 0) {
  31. win = 1;
  32. cout << "jucatorul 0";
  33. break;
  34. }
  35. }
  36. if (mat[1][2] == mat[2][2] && mat[2][2] == mat[3][2]) {
  37. if (mat[i][2] == 1) {
  38. win = 1;
  39. cout << "jucatorul X";
  40. break;
  41. } else if (mat[i][2] == 0) {
  42. win = 1;
  43. cout << "jucatorul 0";
  44. break;
  45. }
  46. }
  47. if (mat[1][3] == mat[2][3] && mat[2][3] == mat[3][3]) {
  48. if (mat[i][3] == 1) {
  49. win = 1;
  50. cout << "jucatorul X";
  51. break;
  52. } else if (mat[i][3] == 0) {
  53. win = 1;
  54. cout << "jucatorul 0";
  55. break;
  56. }
  57. }
  58. if (mat[1][1] == mat[2][2] && mat[2][2] == mat[3][3]) {
  59. if (mat[1][1] == 1) {
  60. win = 1;
  61. cout << "jucatorul X";
  62. break;
  63. } else if (mat[1][1] == 0) {
  64. win = 1;
  65. cout << "jucatorul 0";
  66. break;
  67. }
  68. }
  69. if (mat[1][3] == mat[2][2] && mat[i][2] == mat[3][1]) {
  70. if (mat[1][3] == 1) {
  71. win = 1;
  72. cout << "jucatorul X";
  73. break;
  74. } else if (mat[1][3] == 0) {
  75. win = 1;
  76. cout << "jucatorul 0";
  77. break;
  78. }
  79. }
  80. }
  81. if (win == 0) {
  82. int cont = 0;
  83. for (int i = 1; i <= n; ++i) {
  84. for (int j = 1; j <= n; ++j) {
  85. if (mat[i][j] == 2) {
  86. ++cont;
  87. }
  88. }
  89. }
  90. if (cont >= 1) {
  91. cout << "continua";
  92. return 0;
  93. } else {
  94. cout << "egal";
  95. return 0;
  96. }
  97. }
  98. return 0;
  99. }
Success #stdin #stdout 0.01s 5280KB
stdin
3
2 1 0
1 0 2
0 1 2
stdout
jucatorul 0