Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int num1, num2;
- int sum;
- bool isNotCorrect;
- cout << "Сумма двух чисел бла бла бла" << endl;
- do {
- cout << " Введите число 1" << endl;
- isNotCorrect = false;
- cin >> num1;
- if(cin.fail() or (num1 < 1)) {
- cout << "Ошибка" << endl;
- isNotCorrect = true;
- cin.clear();
- while(cin.get() != '\n');
- }
- } while(isNotCorrect);
- do {
- cout << " Введите число 1" << endl;
- isNotCorrect = false;
- cin >> num2;
- if(cin.fail() or (num2 < 1)) {
- cout << "Ошибка" << endl;
- isNotCorrect = true;
- cin.clear();
- while(cin.get() != '\n');
- }
- } while(isNotCorrect);
- sum = num1 + num2;
- cout << sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement