| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 424 人关注过本帖
标题:求助!~~~
只看楼主 加入收藏
lkz277630964
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-5-2
收藏
 问题点数:0 回复次数:0 
求助!~~~
#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++不久,麻烦看看,顺便解答下哦!
2008-05-05 23:24
快速回复:求助!~~~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017010 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved