-1
void fireShip1(int Numbers2[], bool notFound, int position1, string playerOne, int numberOfSunkenShips, int numberOfShips)
{
numberOfSunkenShips = 0;
while (notFound = true)
{
cout << playerOne << ", please enter a location to fire at." << endl;
cin >> position1;
if (Numbers2[position1] == 0)
{
cout << "You missed!" << endl;
}
else if (Numbers2[position1] == 1)
{
cout << "Bullseye!" << endl;
numberOfSunkenShips++;
cout << "You have sunk " << numberOfSunkenShips << " ships." << endl;
if (numberOfSunkenShips == numberOfShips)
{
notFound = false;
}
Numbers2[position1] = 0;
return;
}
}
cout << playerOne << " has won the match!" << endl;
}
numberofSunkenShips不會高於1.它需要有三個值才能讓我在while循環之外達到「已贏得匹配」字符串。任何幫助?如何轉義while循環? C++
'NOTFOUND == TRUE' – 2014-09-29 18:21:10
你聲明** ** NOTFOUND環以上,並將其設置爲一個初始值爲真? – Lakey 2014-09-29 18:22:06
@Lakey它聲明爲函數的參數。 – Borgleader 2014-09-29 18:22:39