Advertisement
Josif_tepe

Untitled

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