Я делаю крестики-нолики на c++ и столкнулся с проблемой что вне зависимости от значения происходит ветка else Вот код: #include <Windows.h> #include <iostream> #include <string> using namespace std; int main() { byte victory = 0; string test[3][3] = { {" ", " ", " "}, {" ", " ", " "}, {" ", " ", " "} }; byte team = 1;
while (victory == 0) { if (team == 1) { byte mesto; cout << test[0][0] + "|" + test[0][1] + "|" + test[0][2] << endl << test[1][0] + "|" + test[1][1] + "|" + test[1][2] << endl << test[2][0] + "|" + test[2][1] + "|" + test[2][2] << endl; cout << "Enter:" << endl; cout << "1 for cross in highest left cage" << endl; cout << "2 for cross in highest middle cage" << endl; cout << "3 for cross in highest right cage" << endl; cout << "4 for cross in middle left cage" << endl; cout << "5 for cross in middle middlecage" << endl; cout << "6 for cross in middle right cage" << endl; cout << "7 for cross in lowest left cage" << endl; cout << "8 for cross in lowest middle cage" << endl; cout << "9 for cross in lowest right cage" << endl; cin >> mesto; if(mesto == 1 && test[0][0] == " ") { test[0][0] = "X"; } else if (mesto == 2 && test[0][1] == " ") { test[0][1] = "X"; } else if (mesto == 3 && test[0][2] == " ") { test[0][2] = "X"; } else if (mesto == 4 && test[1][0] == " ") { test[1][0] = "X"; } else if (mesto == 5 && test[1][1] == " ") { test[1][1] = "X"; } else if (mesto == 6 && test[1][2] == " ") { test[1][2] = "X"; } else if (mesto == 7 && test[2][0] == " ") { test[2][0] = "X"; } else if (mesto == 8 && test[2][1] == " ") { test[2][1] = "X"; } else if (mesto == 9 && test[2][2] == " ") { test[2][2] = "X"; } else { cout << "There is no such place on the board or this place is already busy" << endl; } team = 2; }
пытался движки искать для плюсов, либо лагает сильно(UE 4), либо документации не найти(UDK), либо чтобы начать писать скрипт для движка, нужно проделать дофига всего непонятного(godot)
Вот код:
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
byte victory = 0;
string test[3][3] = {
{" ", " ", " "},
{" ", " ", " "},
{" ", " ", " "}
};
byte team = 1;
while (victory == 0)
{
if (team == 1)
{
byte mesto;
cout << test[0][0] + "|" + test[0][1] + "|" + test[0][2] << endl << test[1][0] + "|" + test[1][1] + "|" + test[1][2] << endl << test[2][0] + "|" + test[2][1] + "|" + test[2][2] << endl;
cout << "Enter:" << endl;
cout << "1 for cross in highest left cage" << endl;
cout << "2 for cross in highest middle cage" << endl;
cout << "3 for cross in highest right cage" << endl;
cout << "4 for cross in middle left cage" << endl;
cout << "5 for cross in middle middlecage" << endl;
cout << "6 for cross in middle right cage" << endl;
cout << "7 for cross in lowest left cage" << endl;
cout << "8 for cross in lowest middle cage" << endl;
cout << "9 for cross in lowest right cage" << endl;
cin >> mesto;
if(mesto == 1 && test[0][0] == " ")
{
test[0][0] = "X";
} else if (mesto == 2 && test[0][1] == " ")
{
test[0][1] = "X";
} else if (mesto == 3 && test[0][2] == " ")
{
test[0][2] = "X";
} else if (mesto == 4 && test[1][0] == " ")
{
test[1][0] = "X";
} else if (mesto == 5 && test[1][1] == " ")
{
test[1][1] = "X";
} else if (mesto == 6 && test[1][2] == " ")
{
test[1][2] = "X";
} else if (mesto == 7 && test[2][0] == " ")
{
test[2][0] = "X";
} else if (mesto == 8 && test[2][1] == " ")
{
test[2][1] = "X";
} else if (mesto == 9 && test[2][2] == " ")
{
test[2][2] = "X";
} else
{
cout << "There is no such place on the board or this place is already busy" << endl;
}
team = 2;
}