fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. vector<double> tvec;
  10.  
  11. tvec.push_back(2.1);
  12. tvec.push_back(3.2);
  13. tvec.push_back(4.3);
  14. tvec.push_back(NAN);
  15. tvec.push_back(4.5);
  16. tvec.push_back(3.6);
  17.  
  18. for(const double& dv : tvec)
  19. {
  20. if (isnan(dv))
  21. cout << "This is not a number" << endl;
  22. else
  23. cout << dv << endl;
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
2.1
3.2
4.3
This is not a number
4.5
3.6