Advertisement
Spocoman

10. Invalid Number

Sep 5th, 2023 (edited)
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int number;
  7.     cin >> number;
  8.  
  9.     if (number < 100 && number != 0 || number > 200) {
  10.         cout << "invalid" << endl;
  11.     }
  12.  
  13.     return 0;
  14. }
  15.  
  16. Решение с тернарен оператор:
  17.  
  18. #include <iostream>
  19.  
  20. using namespace std;
  21.  
  22. int main() {
  23.     int number;
  24.     cin >> number;
  25.  
  26.     cout << (number < 100 && number != 0 || number > 200 ? "invalid" : "") << endl;
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement