Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <limits>
  5.  
  6. double r()
  7. { double x;
  8. int bad_input; do
  9. { bad_input=0;
  10. ::std::cout << "? ";
  11. ::std::cin >> x;
  12. if(!std::cin)
  13. { ::std::cout << "?REDO FROM START";
  14. bad_input=1;
  15. std::cin.clear();
  16. std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n'); }}
  17. while(bad_input);
  18. return x; }
  19.  
  20. int main()
  21. {
  22. double const x = r();
  23. double const y = r();
  24. ::std::cout << x << '\n';
  25. ::std::cout << y << '\n';
  26. system( "PAUSE" ); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement