码迷,mamicode.com
首页 > 其他好文 > 详细

1000. Parser

时间:2016-10-22 14:43:43      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:string   turn   parser   namespace   end   while   include   base   name   

#include<iostream>
#include<sstream>
#include<iomanip>
using namespace std;
int main(){
 int integer;
 string str;
 double doulb;
 while(cin>>str){
    stringstream strm(str);
    if(strm>>integer &&strm.eof()==1)
         cout << "Integer: " << showbase << hex << integer << endl;
  
    else{
         strm.str(str);
         if(strm>>doulb && strm.eof()==1)
         cout << "Double: " << fixed << setprecision(6) << doulb << endl;
         else
             cout << "String: " <<str<< endl;
   
         }
 }
 return 0;
}

1000. Parser

标签:string   turn   parser   namespace   end   while   include   base   name   

原文地址:http://www.cnblogs.com/sysu-eeman-yang/p/5987387.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!