求助!~~~
#include <iostream.h>#include <string.h>
#include <queue.h>
double consideration(std::string s);
int main(void)
{
std::string s;
int a;
std::getline(cin, s);
while(s!="exit" && s!="EXIT")
{
std::cout << "输入字符串:" << std::endl;
if(!s.empty())
std::cout << s << consideration(s)<< s.size()<< std::endl;
getline(std::cin , s);
}
}
double consideration(std::string s)
{
queue<std::string> que;
char ch;
bool isnum;
std::string str="";
std::string::size_type i;
for (i=0;i!=s.size();++i)
{
ch=s[i];
switch(ch)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '.':
isnum=1;
break;
case '(':
case ')':
case '+':
case '-':
case '*':
case '/':
isnum=0;
break;
default:continue;
}
if (isnum)
{
str+=ch;
std::cout << ch <<endl;
}
else
{
if(!que.empty())
{que.push(str);
str=ch;
que.push(str);
}
}
}
str=que.front();
std::cout << str << endl;
str="";
return 0.000;
}
问题?编译后,第一次输入数后没有问题,再次输入出现错误,不明白是哪里出了问题,刚学C++不久,麻烦看看,顺便解答下哦!