Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int recSor(int mass[],int n);
- //------------------------------------------
- int main()
- {
- cоnst int n = 5;
- int mass[n];
- for(int i = 1; i <= n; ++i)
- cin >> mass;
- recSor(mass,n);
- for(int o = 1; o <= n; ++o )
- cout << mass[o] << " ";
- return 0;
- }
- //------------------------------------------
- int recSor(int mass[],int n)
- {
- int maxi = mass[n],q,m;
- if(n > 1)
- {
- for(int i = 1; i <= n; ++i)
- {
- if(mass > maxi)
- {
- maxi = mass;
- m = i;
- }
- }
- q = mass[n];
- mass[n] = mass[m];
- mass[m] = q;
- recSor(mass, (n - 1));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement