P1_choice
变量正确存储数据,但无法复制\覆盖TTT
数组
我希望将从用户获得的数据存储在p1_choice
变量中,以ttt[0}
数组
请不要拒绝投票,因为我是新来的,我试着遵循所有的指导方针,包括如何正确地提问。
#include <iostream>
#include <cmath>
using namespace std;
//CREATING VARIABLES
string ttt[9] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
string p1_choice;
int p2_choice;
int gametime = 20;
int main()
{
while (gametime < 21) {
cout << endl;
gametime++;
cout << "::: " << ttt[0] << " :: " << ttt[1] << " :: " << ttt[2] << " :::" << endl;
cout << "::: " << ttt[3] << " :: " << ttt[4] << " :: " << ttt[5] << " :::" << endl;
cout << "::: " << ttt[6] << " :: " << ttt[7] << " :: " << ttt[8] << " :::" << endl;
cout << "PLAYER 1 ENTER YOUR COICE HERE........";
cin >> p1_choice;
cout << p1_choice << endl;
p1_choice = ttt[6];
cout << "::: " << ttt[6]
}
return 0;
}
如果您想要覆盖一个变量,您必须这样使用赋值运算符:var_to_overwrite=new_value;
您在代码中做了相反的事情。