You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
3.4 KiB

#include<iostream>
#include<windows.h>
char arr[9] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ' };
void print()
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ" << std::endl;
std::cout << "+---+---+---+" << std::endl;
std::cout << "| " << arr[0] << " | " << arr[1] << " | " << arr[2] << " |" << std::endl;
std::cout << "+---+---+---+" << std::endl;
std::cout << "| " << arr[3] << " | " << arr[4] << " | " << arr[5] << " |" << std::endl;
std::cout << "+---+---+---+" << std::endl;
std::cout << "| " << arr[6] << " | " << arr[7] << " | " << arr[8] << " |" << std::endl;
std::cout << "+---+---+---+" << std::endl;
}
int main()
{
bool n1{ 0 }, n2{ 0 };
system("cls");
print();
int i{ 1 }, k{};
unsigned long long n;//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
int a{ 0 }, b{ 0 };//Ӯ<>ֶԱ<D6B6>
int round{};
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
std::cin >> round;
for (k = 1; k <= round; ++k)
{
for (i = 1; i <= 9; i = i + 1)
{
if (i % 2 == 1)
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>";
std::cin >> n;
if (arr[n - 1] != ' '||n>9||n<1)
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD>" << std::endl;
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>" << std::endl;
i = i - 1;
continue;
}
else
{
arr[n - 1] = 'X';
}
}
else
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>";
std::cin >> n;
if (arr[n - 1] != ' '||n>9||n<1)
{
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD>" << std::endl;
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>" << std::endl;
i = i - 1;
continue;
}
else
{
arr[n - 1] = 'O';
}
}
system("cls");
print();
//<2F><>
if (arr[0] == arr[1] && arr[1] == arr[2] && arr[2] != ' ')
{
if (arr[0] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
else if (arr[3] == arr[4] && arr[4] == arr[5] && arr[5] != ' ')
{
if (arr[3] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
else if (arr[6] == arr[7] && arr[7] == arr[8] && arr[8] != ' ')
{
if (arr[6] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
else if (arr[0] == arr[3] && arr[3] == arr[6] && arr[6] != ' ')
{
if (arr[0] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
else if (arr[1] == arr[4] && arr[4] == arr[7] && arr[7] != ' ')
{
if (arr[1] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
else if (arr[2] == arr[5] && arr[5] == arr[8] && arr[8] != ' ')
{
if (arr[2] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
//б
else if (arr[0] == arr[4] && arr[4] == arr[8] && arr[8] != ' ')
{
if (arr[0] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
else if (arr[6] == arr[4] && arr[4] == arr[2] && arr[2] != ' ')
{
if (arr[6] == 'O')
n2 = 1;
else
n1 = 1;
break;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
if (n1 == 1)
++a;
else if (n2 == 1)
++b;
std::cout << "<EFBFBD>ȷֶԱ<EFBFBD> <20><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2=" << a << ':' << b << std::endl;
n1 = 0, n2 = 0;
for (i = 0; i < 9; ++i)
arr[i] = ' ';
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
if (a>b)
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1 win!!!";
else if (a<b)
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2 win!!!";
else
std::cout << "no winner!!!";
}