Advertisement
Josif_tepe

Untitled

Feb 15th, 2022
840
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. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10.     int n;
  11.     cin >> n;
  12.     int niza[n];
  13.     for(int i = 0; i < n; i++) {
  14.         cin >> niza[i];
  15.     }
  16.     int najgolem = niza[0], najmal = niza[0];
  17.    
  18.     for(int i = 0; i < n; i++) {
  19.         if(najgolem < niza[i]) {
  20.             najgolem = niza[i];
  21.         }
  22.         if(najmal > niza[i]) {
  23.             najmal = niza[i];
  24.         }
  25.     }
  26.     cout << najmal << " "  << najgolem << endl;
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement