Use*_*000 1 c++ if-statement codeblocks
我对ifc ++中的语句有一个小问题.以下是代码片段:
string answer;
cin >> answer;
if (answer == "stay in bed")
{
cout << "You lay there, motionless. Silent.";
}
else if (answer == "go to the bathroom")
{
cout << "You get up and walk across the hall to the bathroom.";
}
else if (answer == "go downstairs")
{
cout << "You get up and walk down the stairs to the kitchen.";
}
else
{
cout << "That is not a valid answer...";
}
Run Code Online (Sandbox Code Playgroud)
当我输入任何值时,我从else语句中获得输出.如,"That is not a valid answer..."
有什么建议?我也在做这一切Code::Blocks.