Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // код на С++, с защитой от неверного ввода.
- C++ (Qt)Выделить код
- #include <iostream>
- #include <cmath>
- using namespace std;
- struct mypoint
- {
- double x;
- double y;
- };
- template <class T>
- bool EnterValue(const char * msg, T &val)
- {
- bool bRet = true;
- cout<<msg;
- if(!(cin>>val))
- bRet = false;
- if(!bRet)
- {
- cin.clear();
- cin.sync();
- }
- return bRet;
- }
- bool EnterPoint(const char * msg, mypoint &pt)
- {
- bool bRet = true;
- cout<<msg<<endl;
- if((bRet = EnterValue("x = ", pt.x)))
- bRet = EnterValue("y = ", pt.y);
- return bRet;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement