#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;
}
}
为什么即使用户输入了正确的选项,这段代码也不会退出循环?
大声读出你的条件 - “运行循环option
is not "water"
or option
is not "beer"
or...".
什么时候应该停止?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)