Advertisement
Spocoman

05. Min and Max

Oct 26th, 2023 (edited)
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n, number,  minNumber = 2147483647, maxNumber = (-2147483647 - 1);
  7.     cin >> n;
  8.  
  9.     for (int i = 0; i < n; i++) {
  10.         cin >> number;
  11.         if (number < minNumber) {
  12.             minNumber = number;
  13.         }
  14.         if (number > maxNumber) {
  15.             maxNumber = number;
  16.         }
  17.     }
  18.  
  19.     cout << minNumber << ' ' << maxNumber << endl;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement