Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
正在运行的if语句下只有一条语句 我用C++编写了一个程序,要求任何整数输入。程序仅在两次迭代后崩溃。代码如下: #include<iostream> int main() { int user_choice; std::cout <<"Please enter any number other than five: "; std::cin >> user_choice; while(user_choice != 5) { std::cout <<"Please enter any number other than five: "; std::cin >> user_choice; if(user_choice == 5) std::cout << "Program Crash"; break; } std::cout << "I told you not to enter 5!"; return 0; } #包括 int main() { int用户选择; std::不能由用户选择; while(用户选择!=5) { std::不能由用户选择; 如果(用户选择==5) std::cout_C++_If Statement_While Loop_Std - Fatal编程技术网

正在运行的if语句下只有一条语句 我用C++编写了一个程序,要求任何整数输入。程序仅在两次迭代后崩溃。代码如下: #include<iostream> int main() { int user_choice; std::cout <<"Please enter any number other than five: "; std::cin >> user_choice; while(user_choice != 5) { std::cout <<"Please enter any number other than five: "; std::cin >> user_choice; if(user_choice == 5) std::cout << "Program Crash"; break; } std::cout << "I told you not to enter 5!"; return 0; } #包括 int main() { int用户选择; std::不能由用户选择; while(用户选择!=5) { std::不能由用户选择; 如果(用户选择==5) std::cout

正在运行的if语句下只有一条语句 我用C++编写了一个程序,要求任何整数输入。程序仅在两次迭代后崩溃。代码如下: #include<iostream> int main() { int user_choice; std::cout <<"Please enter any number other than five: "; std::cin >> user_choice; while(user_choice != 5) { std::cout <<"Please enter any number other than five: "; std::cin >> user_choice; if(user_choice == 5) std::cout << "Program Crash"; break; } std::cout << "I told you not to enter 5!"; return 0; } #包括 int main() { int用户选择; std::不能由用户选择; while(用户选择!=5) { std::不能由用户选择; 如果(用户选择==5) std::cout,c++,if-statement,while-loop,std,C++,If Statement,While Loop,Std,C++不尊重缩进;因此当您编写时: if (counter == 10) std::cout << "Wow you still have not entered 5. You win!"; user_choice = right_answer; 此代码: if (counter == 10) std::cout << "Wow you still have not entered 5. You win!"; user_choice =

C++不尊重缩进;因此当您编写时:

if (counter == 10)
    std::cout << "Wow you still have not entered 5. You win!";
    user_choice = right_answer; 
此代码:

if (counter == 10)
    std::cout << "Wow you still have not entered 5. You win!";
    user_choice = right_answer;

if(条件){statement1;statement2;}
@LogicStuff你能再解释一下你的评论吗你的代码还有更多,比如,你为什么要把
user\u choice
5
literal进行比较,而你应该做
user\u choice==right\u answer
?如果它们已经相等,为什么你觉得有必要将
right\u answer
分配给
user\u choice
??你也已经硬编码了代码> 5代码/代码>输出消息……和代码>我告诉你不要进入5!< /Cord>永远是PRIMTEND.@ MR.Python绝对不,如果你还没有,得到一本C++书。你不能跳进C++和应用其他语言的构造…你会得到像.P.th.MR.Python之类的问题,我建议查一下“范围”。在那里。是的,学习这门语言能让你学得更好真是令人惊讶。
if (counter == 10)
    std::cout << "Wow you still have not entered 5. You win!";
user_choice = right_answer; 
if (counter == 10) {
    std::cout << "Wow you still have not entered 5. You win!";
    user_choice = right_answer; 
}
if (counter == 10)
    std::cout << "Wow you still have not entered 5. You win!";
    user_choice = right_answer;
if (counter == 10)
{
    std::cout << "Wow you still have not entered 5. You win!";
}
user_choice = right_answer;
if (counter == 10)
{
    std::cout << "Wow you still have not entered 5. You win!";
    user_choice = right_answer;
}