C++;从'继续;其他';陈述 我写了一个C++控制台程序来改进我的编程并开始一个文件夹。我的问题是:
在C++;从'继续;其他';陈述 我写了一个C++控制台程序来改进我的编程并开始一个文件夹。我的问题是:,c++,C++,在else语句之后,我如何继续我的故事 我的部分代码是: else { cout << "That's not an answer mate!" << endl; } else{ 您是否可以在时将问题代码包装在一个中,并不断询问,直到给出“正确”的答案: bool error; do { error = false; //some code here.. //if statement to check.. else { cout &l
else
语句之后,我如何继续我的故事
我的部分代码是:
else {
cout << "That's not an answer mate!" << endl;
}
else{
您是否可以在
时将问题代码包装在一个中,并不断询问,直到给出“正确”的答案:
bool error;
do {
error = false;
//some code here..
//if statement to check..
else
{
cout << "That's not an answer mate!" << endl;
error = true;
}
}while(error);
bool错误;
做{
错误=错误;
//这里有一些代码。。
//如果要检查的语句。。
其他的
{
您是否可以在
时将问题代码包装在一个中,并不断询问,直到给出“正确”的答案:
bool error;
do {
error = false;
//some code here..
//if statement to check..
else
{
cout << "That's not an answer mate!" << endl;
error = true;
}
}while(error);
bool错误;
做{
错误=错误;
//这里有一些代码。。
//如果要检查的语句。。
其他的
{
cout您可以使用goto
语句
例如:
Condition1: cout<<"Enter age: ";
cin>>age;
if (age>18){
cout<<"Welcome"<<endl;
//same code...
}
else{
goto Condition1;
}
Condition1:coutage;
如果(年龄>18岁){
cout您可以使用goto
语句
例如:
Condition1: cout<<"Enter age: ";
cin>>age;
if (age>18){
cout<<"Welcome"<<endl;
//same code...
}
else{
goto Condition1;
}
Condition1:coutage;
如果(年龄>18岁){
coutHint:usewhile
开始使用结构化编程。你的思维方式是“先到X,再到Y,再到Z”。你需要循环。关于编程的每一本入门书都涉及循环。我的朋友,你是个聪明人。谢谢:)提示:usewhile
开始使用结构化编程。你的思维方式是“到X,再到Y,再到Z"。你需要循环。每一本关于编程的入门书都有循环。我的朋友,你是个聪明人。谢谢:)建议初学者使用goto。你一定是在开玩笑。在这一点上,我必须同意@MuhammetAliAsan的观点-goto是一种可怕的做法。值得注意的是…@Muhammet Ali Asan,cc@EJoshuaSAdvising要使用goto给初学者。你必须e Joking我不得不同意@MuhammetAliAsan在这一点上的观点-goto是一种可怕的做法。感谢地注意到…@Muhammet Ali Asan,cc@EJoshuaS