Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
Loops 而循环不会返回到循环中_Loops_Menu_While Loop_Stack_Main - Fatal编程技术网

Loops 而循环不会返回到循环中

Loops 而循环不会返回到循环中,loops,menu,while-loop,stack,main,Loops,Menu,While Loop,Stack,Main,我一直在做一个项目,我几乎要完成最后一个问题是创建一个while循环,不断询问用户是否要转换表达式。到目前为止,它只做了一次,然后就不再继续问了。我知道这是一个简单的问题,我想我有逻辑,但出于某种原因,它不起作用 以下是我的主要观点: int main(){ string answer=" "; string expression; while(answer!="no"){ cout<<"Would you like to do a conversion,type yes

我一直在做一个项目,我几乎要完成最后一个问题是创建一个while循环,不断询问用户是否要转换表达式。到目前为止,它只做了一次,然后就不再继续问了。我知道这是一个简单的问题,我想我有逻辑,但出于某种原因,它不起作用

以下是我的主要观点:

int main(){
string answer=" ";

string expression;

while(answer!="no"){
    cout<<"Would you like to do a conversion,type yes or no:";
getline(cin,answer);

    cout<<" Enter a Post Fix expression:";


getline(cin,expression);
convert(expression);

}



return 0;

}
intmain(){
字符串答案=”;
字符串表达式;
while(回答!=“否”){

我试过这个代码,它是从你的代码中复制过来的,效果很好。这让我得出结论,我不明白问题是什么或者你想要什么

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
int main(){
    string answer=" ";
    string expression;

    while(answer!="no"){
        cout<<"Would you like to do a conversion,type yes or no:";
        getline(cin,answer);

        cout<<" Enter a Post Fix expression:";

        getline(cin,expression);
        // do something
    }

    return 0;
}
#包括
#包括
#包括
#包括
使用名称空间std;
int main(){
字符串答案=”;
字符串表达式;
while(回答!=“否”){

我试过这个代码,它是从你的代码中复制过来的,效果很好。这让我得出结论,我不明白问题是什么或者你想要什么

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
int main(){
    string answer=" ";
    string expression;

    while(answer!="no"){
        cout<<"Would you like to do a conversion,type yes or no:";
        getline(cin,answer);

        cout<<" Enter a Post Fix expression:";

        getline(cin,expression);
        // do something
    }

    return 0;
}
#包括
#包括
#包括
#包括
使用名称空间std;
int main(){
字符串答案=”;
字符串表达式;
while(回答!=“否”){

cout我还运行了你的代码,while循环对我很有效。 也许您可以从注释转换(表达式)开始;从那里调用并调试

#include <iostream>
using namespace std;


int main(){
string answer=" ";

string expression;

while(answer!="no"){
cout<<"Would you like to do a conversion,type yes or no:";
getline(cin,answer);

cout<<" Enter a Post Fix expression:";


getline(cin,expression);
/*convert(expression);*/

}



return 0;

}
#包括
使用名称空间std;
int main(){
字符串答案=”;
字符串表达式;
while(回答!=“否”){

cout我还运行了你的代码,while循环对我很有效。 也许您可以从注释转换(表达式)开始;从那里调用并调试

#include <iostream>
using namespace std;


int main(){
string answer=" ";

string expression;

while(answer!="no"){
cout<<"Would you like to do a conversion,type yes or no:";
getline(cin,answer);

cout<<" Enter a Post Fix expression:";


getline(cin,expression);
/*convert(expression);*/

}



return 0;

}
#包括
使用名称空间std;
int main(){
字符串答案=”;
字符串表达式;
while(回答!=“否”){

coutI再次尝试,但没有返回到第一个问题。我想可能是我的convert函数关闭了它。我不确定。当你按照编写的方式运行程序时,你说它只运行一次循环。接下来会发生什么?程序会终止还是卡住?我试图获取的是你的convert()吗函数被卡在无限循环或阻塞上,或者您的convert()上函数抛出了一些错误,导致程序终止。我再次尝试了它,但它没有返回到第一个问题。我想可能是我的转换函数关闭了它。我不确定。当你按照编写的方式运行程序时,你说它只运行一次循环。接下来会发生什么?程序终止还是卡住?W我想知道的是convert()函数是卡在无限循环中还是阻塞中,还是convert()函数函数抛出了一些错误,导致程序终止。我非常确信这是我的转换方法,因为它在注释掉它之后工作。我不知道我的转换方法出了什么问题。我非常确信这是我的转换方法,因为它在注释掉它之后工作。我不知道是什么我的转换方法有误。