首页 > 其他 > 详细

1000. Parser

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

#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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!