Advertisement
Spocoman

08. Number sequence

Sep 6th, 2023
956
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <climits>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int numberCount;
  8.     cin >> numberCount;
  9.  
  10.     int number;
  11.  
  12.     int maxNumber = INT_MIN;
  13.     int minNumber = INT_MAX;
  14.  
  15.     for (int i = 0; i < numberCount; i++)
  16.     {
  17.         cin >> number;
  18.  
  19.         if (number < minNumber) {
  20.             minNumber = number;
  21.         }
  22.         if (number > maxNumber) {
  23.             maxNumber = number;
  24.         }
  25.     }
  26.  
  27.     cout << "Max number: " << maxNumber << endl;
  28.     cout << "Min number: " << minNumber << endl;
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement