fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 3;
  5.  
  6. int main() {
  7. int player0 = 0, playerX = 0;
  8. int matrix[MAX_SIZE][MAX_SIZE], notComplete = 0;
  9. for (int i = 0; i < MAX_SIZE; ++i) {
  10. for (int j = 0; j < MAX_SIZE; ++j) {
  11. cin >> matrix[i][j];
  12. if (j == MAX_SIZE - 1) {
  13. if (matrix[i][j] == 0 && matrix[i][j - 1] == 0 && matrix[i][j - 2] == 0) {
  14. ++player0;
  15. } else if (matrix[i][j] == 1 && matrix[i][j - 1] == 1 && matrix[i][j - 2] == 1) {
  16. ++playerX;
  17. }
  18. if (i == MAX_SIZE - 1) {
  19. if (matrix[i][j] == 0 && matrix[i - 1][j - 1] == 0 && matrix[i - 2][j - 2] == 0) {
  20. ++player0;
  21. } else if (matrix[i][j] == 1 && matrix[i - 1][j - 1] == 1 && matrix[i - 2][j - 2] == 1) {
  22. ++playerX;
  23. }
  24. }
  25. } else if (i == MAX_SIZE - 1) {
  26. if (matrix[i][j] == 0 && matrix[i - 1][j] == 0 && matrix[i - 2][j] == 0) {
  27. ++player0;
  28. } else if (matrix[i][j] == 1 && matrix[i - 1][j] == 1 && matrix[i - 2][j] == 1) {
  29. ++playerX;
  30. }
  31. if (j == 0) {
  32. if (matrix[i][j] == 0 && matrix[i - 1][j + 1] == 0 && matrix[i - 2][j + 2] == 0) {
  33. ++player0;
  34. } else if (matrix[i][j] == 1 && matrix[i - 1][j + 1] == 1 && matrix[i - 2][j + 2] == 1) {
  35. ++playerX;
  36. }
  37. }
  38. }
  39. if (matrix[i][j] == 2) {
  40. notComplete = 1;
  41. }
  42. }
  43. }
  44. if (player0 != playerX) {
  45. cout << "Jucătorul ";
  46. if (player0 > playerX) {
  47. cout << 0;
  48. } else {
  49. cout << 1;
  50. }
  51. } else if (notComplete) {
  52. cout << "Continuă";
  53. } else {
  54. cout << "Egal";
  55. }
  56. return 0;
  57. }
Success #stdin #stdout 0.01s 5292KB
stdin
0 0 0
0 0 0
0 0 0
stdout
Jucătorul 0