#include <iostream>
#include <string>
using namespace std;
int main()
{
string option;
cout << "Would like water, beer, or rum?--> ";
cin >> option;
while(option != "water" || option != "beer" || option != "rum")
{
cout << "You did not choose a valid option. Try again.\n";
cout << "Would you like water, beer, or rum?-->";
cin >> option;
}
}
爲什麼這個代碼不會退出循環,即使用戶輸入正確的選項?C++雖然循環不工作
@ user1816640沒問題。 – 0x499602D2