Advertisement
PIBogdanov

C++

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