Advertisement
Josif_tepe

Untitled

Dec 4th, 2022
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7.     int n;
  8.     cin >> n;
  9.    
  10.     int niza[n];
  11.    
  12.     for(int i = 0; i < n; i++) {
  13.         cin >> niza[i];
  14.     }
  15.    
  16.     int najgolem_broj = niza[0];
  17.     int najmal_broj = niza[0];
  18.    
  19.     for(int i = 0; i < n; i++) {
  20.         if(niza[i] > najgolem_broj) {
  21.             najgolem_broj = niza[i];
  22.         }
  23.         if(niza[i] < najmal_broj) {
  24.             najmal_broj = niza[i];
  25.         }
  26.     }
  27.     cout << "Najgolem broj: " << najgolem_broj << endl;
  28.     cout << "Najmal broj: " << najmal_broj << endl;
  29.  
  30.     return 0;
  31. }
  32. /*
  33.  5
  34.  2 3 5 1 8
  35.  
  36.  **/
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement