Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- long long n,y,i,z,x=0,MIN1,MIN2,MIN3;
- cin>> n ;
- cin>> x >> y;
- MIN1=min(x,y);
- MIN2=max(x,y);
- for(i=1;i<=n-2;i++){
- cin>>x;
- if(x<=MIN1){
- MIN3=MIN2;
- MIN2=MIN1;
- MIN1=x;
- }
- else{
- if(x<=MIN2 && x>MIN1){
- MIN3=MIN2;
- MIN2=x;
- }
- else{
- if(x<=MIN3 && x>MIN2){
- MIN3=x;
- }
- }
- }
- }
- cout<< MIN3 << " " << MIN2 << " " <<MIN1;
- return 0;
- }
Add Comment
Please, Sign In to add comment