Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- ///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.
- using namespace std;
- int main()
- {
- int a[50],n;
- cout<<"N ";cin>>n;
- for(int i=1;i<=n;i++) cin>>a[i];
- int jo,c,nn=n;
- do
- {
- jo=1;
- for(int i=1;i<=nn-1;i++)
- if (a[i]>a[i+1])
- { c=a[i];
- a[i]=a[i+1];
- a[i+1]=c;
- jo=0;
- }
- } while (jo==0);
- cout<<"A jegyek novekvo sorrendben:";
- for(int i=1;i<=n;i++) cout<<a[i]<<" ";
- cout<<endl;
- cout<<"Az elso 3 lgnagyobb jegy:";
- for(int i=n;i>n-3;i--) cout<<a[i]<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment