Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- const int MIN = 0;
- const int MAX = 100;
- int num;
- bool IsIncorrect;
- do {
- IsIncorrect = false;
- cin >> num;
- if (cin.fail())
- {
- IsIncorrect = true;
- cout << "TYPR ERR" << endl;
- cin.clear();
- while (cin.get() != '\n');
- }
- if (!IsIncorrect && (num < MIN || num > MAX))
- {
- IsIncorrect = true;
- cout << "RANGE ERR" << endl;
- }
- if (cin.get() != '\n')
- {
- cout << "Err";
- IsIncorrect = true;
- cin.clear();
- while (cin.get() != '\n');
- cout << endl;
- }
- } while (IsIncorrect);
- cout << num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement