Advertisement
Guest User

Untitled

a guest
Jul 25th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int recSor(int mass[],int n);
  6. //------------------------------------------
  7. int main()
  8. {
  9. cоnst int n = 5;
  10. int mass[n];
  11. for(int i = 1; i <= n; ++i)
  12. cin >> mass;
  13. recSor(mass,n);
  14. for(int o = 1; o <= n; ++o )
  15. cout << mass[o] << " ";
  16. return 0;
  17. }
  18. //------------------------------------------
  19. int recSor(int mass[],int n)
  20. {
  21. int maxi = mass[n],q,m;
  22.  
  23. if(n > 1)
  24. {
  25. for(int i = 1; i <= n; ++i)
  26. {
  27. if(mass > maxi)
  28. {
  29. maxi = mass;
  30. m = i;
  31. }
  32. }
  33. q = mass[n];
  34. mass[n] = mass[m];
  35. mass[m] = q;
  36. recSor(mass, (n - 1));
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement