fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 100 ;
  4. int a[N] ;
  5. int main() {
  6. int n ;
  7. cin>>n ;
  8. for(int i = 0 ; i < n ; i++)
  9. cin>>a[i] ;
  10. sort(a, a + n) ;
  11. cout<<a[n-1]<<' '<<a[n-2]<<'\n' ; /// a[n] for maximum element, and a[n-2] for the second maximum element
  12. return 0;
  13. }
Success #stdin #stdout 0s 5284KB
stdin
5
2 3 5 1 4
stdout
5 4