Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n ,max1=-1e9,max2=-1e9,max3=-1e9 ;
- cin>>n;// Nhap so luong phan tu
- for(int i = 0;i<n;i++)
- {
- int temp;cin>>temp; //nhap cac phan tu khong trung nhau
- if(temp <=max3) continue;
- if(temp > max1)
- {
- max3=max2;
- max2=max1;
- max1=temp;
- }
- else if(temp>max2)
- {
- max3=max2;
- max2=temp;
- }
- else
- {
- max3=temp;
- }
- }
- if(n==1) cout<<max1;
- if(n==2) cout<<max1<<" "<<max2;
- if(n>=3) cout<<max1<<" "<<max2<<" "<<max3;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement