Advertisement
irmantas_radavicius

Untitled

Feb 20th, 2024
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <cctype>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9.  
  10.     int x;
  11.     while(1){
  12.         cout << "Iveskite skaiciu: ";
  13.         cin >> x;
  14.         char c = cin.get();
  15.         if(cin.fail() || (c != '\n')){
  16.             cout << "Blogas ivedimas!" << endl;
  17.             cin.clear();
  18.             cin.ignore(1024, '\n');
  19.  
  20.         } else
  21.             break;
  22.     }
  23.  
  24.     // x yra geras
  25.     cout << "Tu ivedei " << x << endl;
  26.  
  27.     return 0;
  28.  
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement