Advertisement
PIBogdanov

C++ code

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