Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- #if defined(_WIN32) || defined(_WIN64)
- #pragma execution_character_set("utf-8")
- #include<Windows.h>
- const auto _dummy_ = []()
- {
- SetConsoleCP(65001);
- SetConsoleOutputCP(65001);
- return 0;
- }();
- #endif
- using namespace std;
- int main()
- {
- srand(static_cast<unsigned int>(time(0)));
- int lever1 = 1;
- bool lever2 = false;
- char xo1 = '_';
- char xo2 = '_';
- char xo3 = '_';
- char xo4 = '_';
- char xo5 = '_';
- char xo6 = '_';
- char xo7 = '_';
- char xo8 = '_';
- char xo9 = '_';
- while (lever1 != 0)
- {
- int cell1 = 1;
- int cell2 = 2;
- int cell3 = 3;
- int cell4 = 4;
- int cell5 = 5;
- int cell6 = 6;
- int cell7 = 7;
- int cell8 = 8;
- int cell9 = 9;
- cout << cell1 << "|";
- cout << xo1 << "|";
- cout << cell2 << "|";
- cout << xo2 << "|";
- cout << cell3 << "|";
- cout << xo3 << "|";
- cout << "\n" << cell4 << "|";
- cout << xo4 << "|";
- cout << cell5 << "|";
- cout << xo5 << "|";
- cout << cell6 << "|";
- cout << xo6 << "|";
- cout << "\n" << cell7 << "|";
- cout << xo7 << "|";
- cout << cell8 << "|";
- cout << xo8 << "|";
- cout << cell9 << "|";
- cout << xo9 << "|\n";
- if (lever2 == true)
- {
- cout << "конец игры\n";
- lever1 = 0;
- }
- cout << "Выберите номер ячейки\n";
- int number;
- cin >> number;
- switch (number)
- {
- case 1:
- cout << "'x' или 'o'\n";
- cin >> xo1;
- break;
- case 2:
- cout << "'x' или 'o'\n";
- cin >> xo2;
- break;
- case 3:
- cout << "'x' или 'o'\n";
- cin >> xo3;
- break;
- case 4:
- cout << "'x' или 'o'\n";
- cin >> xo4;
- break;
- case 5:
- cout << "'x' или 'o'\n";
- cin >> xo5;
- break;
- case 6:
- cout << "'x' или 'o'\n";
- cin >> xo6;
- break;
- case 7:
- cout << "'x' или 'o'\n";
- cin >> xo7;
- break;
- case 8:
- cout << "'x' или 'o'\n";
- cin >> xo8;
- break;
- case 9:
- cout << "'x' или 'o'\n";
- cin >> xo9;
- break;
- }
- if ((xo1 == 'x' && xo2 == 'x' && xo3 == 'x') || (xo1 == 'x'
- && xo4 == 'x' && xo7 == 'x') || (xo1 == 'x' && xo5 == 'x' && xo9 == 'x'))
- {
- cout << "x выиграл\n";
- lever2 == true;
- }
- else if ((xo2 == 'x' && xo5 == 'x' && xo8 == 'x') || (xo4 == 'x' && xo5 == 'x' && xo6 == 'x'))
- {
- cout << "x выиграл\n";
- lever2 == true;
- }
- else if ((xo3 == 'x' && xo5 == 'x' && xo7 == 'x') || (xo3 == 'x' && xo6 == 'x'
- && xo9 == 'x') || (xo7 == 'x' && xo8 == 'x' && xo9 == 'x'))
- {
- cout << "x выиграл\n";
- lever2 == true;
- }
- else if ((xo1 == 'o' && xo2 == 'o' && xo3 == 'o') || (xo1 == 'o'
- && xo4 == 'o' && xo7 == 'o') || (xo1 == 'o' && xo5 == 'o' && xo9 == 'o'))
- {
- cout << "o выиграл\n";
- lever2 == true;
- }
- else if ((xo2 == 'o' && xo5 == 'o' && xo8 == 'o') || (xo4 == 'o' && xo5 == 'o' && xo6 == 'o'))
- {
- cout << "o выиграл\n";
- lever2 == true;
- }
- else if ((xo3 == 'o' && xo5 == 'o' && xo7 == 'o') || (xo3 == 'o' && xo6 == 'o'
- && xo9 == 'o') || (xo7 == 'o' && xo8 == 'o' && xo9 == 'o'))
- {
- cout << "o выиграл\n";
- lever2 == true;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement