desislava_topuzakova

08. Number sequence

Jan 31st, 2022
1,034
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. #include <string>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int n;
  9.     cin >> n;
  10.     int max = INT_MIN;
  11.     int min = INT_MAX;
  12.     for (int i = 0; i < n; i++) {
  13.         int currentNumber;
  14.         cin >> currentNumber;
  15.  
  16.         if (currentNumber > max)
  17.         {
  18.             max = currentNumber;
  19.         }
  20.         if (currentNumber < min)
  21.         {
  22.             min = currentNumber;
  23.         }
  24.     }
  25.     cout << "Max number: " << max << endl;
  26.     cout << "Min number: " << min << endl;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment