Advertisement
Josif_tepe

Untitled

Jan 24th, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n;
  7.     cin >> n;
  8.    
  9.     int niza[n];
  10.     for(int i = 0; i < n; i++) {
  11.         cin >> niza[i];
  12.     }
  13.    
  14.     int najmal_element = niza[0];
  15.     int najgolem_element = niza[0];
  16.    
  17.     for(int i = 0; i < n; i++) {
  18.         if(niza[i] < najmal_element) {
  19.             najmal_element = niza[i];
  20.         }
  21.        
  22.         if(niza[i] > najgolem_element) {
  23.             najgolem_element = niza[i];
  24.         }
  25.     }
  26.     cout << najmal_element << endl;
  27.     cout << najgolem_element << endl;
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement