GerexD

gy31_10

Apr 3rd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. ///10. Egy sportverseny eredményeit egy tömbben tároljuk. N versenyző van. Ird ki az elért pontszámokat növekvő sorrendbe, majd írd ki a három legnagyobb pontszámot.
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a[50],n;
  8. cout<<"N ";cin>>n;
  9. for(int i=1;i<=n;i++) cin>>a[i];
  10. int jo,c,nn=n;
  11. do
  12. {
  13. jo=1;
  14. for(int i=1;i<=nn-1;i++)
  15. if (a[i]>a[i+1])
  16. { c=a[i];
  17. a[i]=a[i+1];
  18. a[i+1]=c;
  19. jo=0;
  20. }
  21. } while (jo==0);
  22. cout<<"A jegyek novekvo sorrendben:";
  23. for(int i=1;i<=n;i++) cout<<a[i]<<" ";
  24. cout<<endl;
  25. cout<<"Az elso 3 lgnagyobb jegy:";
  26. for(int i=n;i>n-3;i--) cout<<a[i]<<" ";
  27.  
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment