Răspuns :
#include <iostream>
using namespace std;
int main() {
int n,t,m1,m2,i;
cin>>n>>m1>>m2;
for(i=0,n-=2;i<n;i++,cin>>t){
if(t>m1){
if(m2<m1)m2=m1;
m1=t;
}else if(t>m2)m2=t;
}
if(m1<m2)switch(m1,m2);
cout<<max(m1,m2)<<" "<<m2;
}
using namespace std;
int main() {
int n,t,m1,m2,i;
cin>>n>>m1>>m2;
for(i=0,n-=2;i<n;i++,cin>>t){
if(t>m1){
if(m2<m1)m2=m1;
m1=t;
}else if(t>m2)m2=t;
}
if(m1<m2)switch(m1,m2);
cout<<max(m1,m2)<<" "<<m2;
}
#include <iostream>
using namespace std;
int main(){ int n,i,v[i],a=0,b=0,x; cin>>n; for(i=0;i<=n-1;i++){ cin>>v[i]; } a=v[0]; b=v[0]; for(i=0;i<=n-1;i++){ if(a<v[i]) a=v[i]; x=i; } for(i=0;i<=n-1;i++){ if(b<v[i] and i!=x){ b=v[i]; } } cout<<a<<" "<<b;}
using namespace std;
int main(){ int n,i,v[i],a=0,b=0,x; cin>>n; for(i=0;i<=n-1;i++){ cin>>v[i]; } a=v[0]; b=v[0]; for(i=0;i<=n-1;i++){ if(a<v[i]) a=v[i]; x=i; } for(i=0;i<=n-1;i++){ if(b<v[i] and i!=x){ b=v[i]; } } cout<<a<<" "<<b;}