fork(9) download
  1. #include<iostream>
  2. #include<sstream>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. string s;
  9.  
  10. cin >> s;
  11.  
  12. stringstream ss;
  13. ss << s;
  14.  
  15. float num = 0;
  16.  
  17. ss >> num;
  18.  
  19. if(ss.good()) {
  20. cerr << "No Valid Number" << endl;
  21. }
  22. else if(num == 0 && s[0] != 0) {
  23. cerr << "No Valid Number" << endl;
  24. }
  25. else {
  26. cout << num << endl;
  27. }
  28. }
Success #stdin #stdout 0s 3032KB
stdin
+88.8888
stdout
88.8888