Advertisement
yejolga

ol_4_12

Nov 2nd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10.     ifstream cin("input.txt");
  11.  
  12.     short n;
  13.     cin>>n;
  14.     long c[n];
  15.  
  16.     long mx=-1000000, mx2=-1000001;
  17.     for (short i = 0; i<n; i++)
  18.     {
  19.         cin>>c[i];
  20.         mx = max(c[i], mx);
  21.     }
  22.  
  23.     bool f = false;
  24.     for (short i = 0; i<n; i++)
  25.         if (c[i]== mx)
  26.             if(!f)
  27.                 f = true;
  28.             else
  29.                 mx2 = max(c[i], mx2);
  30.         else
  31.             mx2 = max(c[i], mx2);
  32.     cout<<mx2;
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement