Advertisement
Guest User

Arraymax3

a guest
Feb 23rd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int main(){
  5. int m_1,m_2,m_3;
  6. int temp;
  7. int dem = 0;
  8. m_1=m_2=m_3=INT_MIN;
  9. while(cin>>temp){
  10. if (temp>m_1)
  11. {
  12. m_3=m_2;
  13. m_2=m_1;
  14. m_1=temp;
  15. }
  16. else{
  17. if(temp>m_2)
  18. {
  19. m_3=m_2;
  20. m_2=temp;
  21. }
  22. else
  23. {
  24. if (temp>m_3)
  25. m_3=temp;
  26. }
  27. }
  28. dem++;
  29. }
  30. if (dem==1) cout<<m_1;
  31. else
  32. if (dem==2) cout<<m_1<<" "<<m_2;
  33. else cout<< m_1<<" "<<m_2<<" "<<m_3;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement