Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TicTacToe.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- char map[9] = {
- '1', '2', '3',
- '4', '5', '6',
- '7', '8', '9',
- };
- void Frame() {
- system("cls");
- cout << " | | " << endl;
- cout << " " << map[6] << " | " << map[7] << " | " << map[8] << endl;
- cout << "___|___|___" << endl;
- cout << " | | " << endl;
- cout << " " << map[3] << " | " << map[4] << " | " << map[5] << endl;
- cout << "___|___|___" << endl;
- cout << " | | " << endl;
- cout << " " << map[0] << " | " << map[1] << " | " << map[2] << endl;
- cout << " | | " << endl;
- }
- bool CheckWin() {
- return false;
- }
- int main()
- {
- int step = 0;
- int choice;
- char xo[2] = { 'X', 'O' };
- Frame();
- while (step < 9) {
- cout << "Step of: " << xo[step % 2] << endl;;
- while (true) {
- cin >> choice;
- if (map[choice - 1] != xo[0] && map[choice - 1] != xo[1]) {
- map[choice - 1] = xo[step % 2];
- break;
- }
- else
- cout << "Try again." << endl;
- }
- step++;
- Frame();
- if (step > 5) {
- if ( CheckWin() ) {
- cout << "Win " << xo[step % 2];
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement