当输入一个介于 1 到 7 之间的值时,程序应该检查该值是否为 1 到 7 以及输入的数字数组中的值是否不为 0 但该程序的问题是,如果值 House[0]或其他数组为 0 程序没有循环它继续运行
do
{
cout << "Player 1\n";
cout << "Please choose your location (1 to 7) => ";
cin >> h1in ; // player 1 enters a value
cin.clear();// used to clear the value if a str value is entered
cin.ignore(1000,'\n');// used to clear the value if a str value is entered
if ((h1in<1)||(h1in>7))
{
cout << "You entered the wrong input \n\n";
}
if(house[h1in-1]==0)
{
cout<<"jde";
}
} while((house[h1in-1]!=0)&(h1in<1)||(h1in>7));
if (h1in==1)
{
for(int i=1;i<7;i++){
house[0]--;
house[i]++;
if(i==6){
storehouse[0]++;
seeds--;
house[0]--;
}
printout();
}
}
else if(h1in==2)
{
for(int i=1;i<7;i++){
house[1]--;
house[i+1]++;
if(i==6){
storehouse[0]++;
seeds--;
house[1]--;
}
printout();
}
}
else if(h1in==3)
{
for(int i=1;i<7;i++)
{
house[2]--;
house[i+2]++;
if(i==6){
storehouse[0]++;
seeds--;
house[2]--;
}
printout();
}
}
else if(h1in==4)
{
for(int i=1;i<7;i++)
{
house[3]--;
house[i+3]++;
if(i==6){
storehouse[0]++;
seeds--;
house[3]--;
}
printout();
}
}
else if(h1in==5)
{
for(int i=1;i<7;i++)
{
house[4]--;
house[i+4]++;
if(i==6){
storehouse[0]++;
seeds--;
house[4]--;
}
printout();
}
}
else if(h1in==6)
{
for(int i=1;i<7;i++)
{
house[5]--;
house[i+5]++;
if(i==6){
storehouse[0]++;
seeds--;
house[5]--;
}
printout();
}
}
else if(h1in==7)
{
for(int i=1;i<7;i++)
{
house[6]--;
house[i+6]++;
if(i==6){
storehouse[0]++;
seeds--;
house[6]--;
}
printout();
}
}