首页 > 代码库 > 1000. Parser

1000. Parser

#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