Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //se citesc n nr naturale ..sa se afiseze cele mai mari 3 nr pare
- #include <iostream>
- #include<climits>
- int n,m1=INT_MIN,m2=INT_MIN,m3=INT_MIN;
- using namespace std;
- void sortare()
- {
- if(m1>m2)
- swap(m1,m2);
- if(m1>m3)
- swap(m1,m3);
- if(m2>m3)
- swap(m2,m3);
- }
- void greedy()
- {
- int x,i;
- for(i=1;i<=n;i++)
- {
- cin>>x;
- if(x%2==0)
- {
- if(x>m1)
- m1=x;
- sortare();
- }
- }
- }
- int main()
- {
- cin>>n;
- greedy();
- if(m1==INT_MIN || m2==INT_MIN || m3==INT_MIN)
- cout<<"Nu exista";
- else
- cout<<m1<<" " <<m2<<" "<<m3;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement