Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- string winner = "";
- void cek(char c) {
- if (c == 'O') winner = "Aneb";
- else if (c == 'X') winner = "Amar";
- }
- int main() {
- char c[3][3];
- bool isFull = true;
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- cin >> c[i][j];
- if (c[i][j] == '*') isFull = false;
- }
- }
- for (int i = 0; i < 3; i++) {
- if (c[i][0] == c[i][1] && c[i][1] == c[i][2]) {
- cek(c[i][0]);
- }
- if (c[0][i] == c[1][i] && c[1][i] == c[2][i]) {
- cek(c[0][i]);
- }
- }
- if (c[0][0] == c[1][1] && c[1][1] == c[2][2]) {
- cek(c[1][1]);
- }
- if (c[2][0] == c[1][1] && c[1][1] == c[0][2]) {
- cek(c[1][1]);
- }
- if (winner != "") cout << winner << " Menang";
- else {
- if (isFull) cout << "Seri";
- else cout << "Permainan Belum Selesai";
- }
- }
Add Comment
Please, Sign In to add comment