1. #include<iostream> 
  2. #include<sstream> 
  3. #include<string> 
  4. using namespace std; 
  5.  
  6.  
  7. template<class out_type,class in_value> 
  8. out_type convert(const in_value & t) 
  9. stringstream stream; 
  10. stream<<t;//向流中传值 
  11. out_type result;//这里存储转换结果 
  12. stream>>result;//向result中写入值 
  13. return result; 
  14.  
  15.  
  16. int main() 
  17.     string s; 
  18.     while(cin>>s) 
  19.     { 
  20.         double valdou=convert<double>(s);  
  21.         int valint=convert<int>(s);  
  22.         cout<<valdou<<endl; 
  23.         cout<<valint<<endl; 
  24.         
  25.        
  26.     } 
  27.  
  28.  
  29.     return 0;