URGENT HELP PLEASE

You should prompt the user to input either 1 or 2, signifying they prefer either the first or second restaurant, respectively
If the user provides a response that is neither of the restaurants in the current match, reprompt the user until valid information is entered

string tournament(vector<string>&restaurants)
{
const int POWER_BASE = 2;
int integerExponent = log(restaurants.size()) / log(POWER_BASE);
double doubleExponent = log(restaurants.size()) / log(POWER_BASE);
int i = 0;
vector<string> losers;
string restaurantName = "";

if (doubleExponent == integerExponent)
{
do
{
for (int i = 0; i < restaurants.size() - 1; i += 2)
{
string opponent1 = restaurants[i];
string opponent2 = restaurants[i + 1];
cout << endl << "1. " << opponent1 << " or " << "2. "<< opponent2 << endl;
string winner;
getline(cin, winner);

while (winner != restaurants[i] && winner != restaurants[i + 1])
{
cout << "Invalid, please re-enter" << endl;
getline(cin, winner);

}
if (winner == opponent1)
{
restaurantName = opponent2;
losers.push_back(restaurantName);
}
else if (winner == opponent2)
{
restaurantName = opponent1;
losers.push_back(restaurantName);
}
}
for (int i = 0; i < losers.size(); i++)
{
restaurantName = losers[i];
removeLoserRestaurant(restaurantName, restaurants);
}
losers.clear();
printRestaurants(restaurants);
} while (restaurants.size() > 1);
cout << "The winner is " << restaurants[0] << endl;
}
else
{
cout << "Could not begin tournament. There is not enough restaurants in the tournament. Please add or remove a restaurant." << endl;
}
return restaurantName;
}
Can you please give a more in-depth explanation of your program's purpose? I'd be happy to help.
Last edited on
Topic archived. No new replies allowed.