Guest User

Untitled

a guest
Jun 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. void swap(int *a, int *b){
  2.     if(a != b){
  3.         int t = *a;
  4.         *a = *b;
  5.         *b = *t;
  6.     }
  7. }
  8.  
  9. int *max(int *arr, int size){
  10.     int *m = arr + (--size);
  11.     while(size--)
  12.         if(*m > arr[size]) m = arr + size;
  13.     return m;
  14. }
  15.  
  16. void max_sort(int *arr, int size){//сортировка по убыванию "максимумами"
  17.     swap(max(arr, size), arr);
  18.     max_sort(arr+1, size-1);
  19. }
Add Comment
Please, Sign In to add comment