Advertisement
STANAANDREY

BAC 4/19/2022 6

Apr 19th, 2022 (edited)
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <climits>
  4. using namespace std;
  5. ifstream fin("bac.txt");
  6.  
  7. int main() {
  8.     int x;
  9.     fin >> x;
  10.     int maxi = INT_MIN, mini = INT_MAX;
  11.     bool ok = false;
  12.     if (9 < x && x < 100) {
  13.         maxi = mini = x;
  14.         ok = true;
  15.     }
  16.     while (fin >> x) {
  17.         if (9 < x && x < 100) {
  18.             ok = true;
  19.             if (mini > x) {
  20.                 mini = x;
  21.             }
  22.             if (maxi < x) {
  23.                 maxi = x;
  24.             }
  25.         }
  26.     }
  27.     if (!ok) {
  28.         cout << "nu exista" << endl;
  29.     } else {
  30.         cout << mini - 1 << ' ' << maxi + 1 << endl;
  31.     }
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement