Advertisement
Guest User

Untitled

a guest
Jul 7th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. void sort(int values[], int n);
  5. int main(void)
  6. {
  7. int values[5]={4,2,5,3,1};
  8. int n =5;
  9. void(values,n);
  10.  
  11. for(int b=0;b<n;b++)
  12.     {
  13.     printf("%d\n", values[b])
  14.     }
  15. }
  16. void sort(int values[], int n)
  17. {
  18.     for (int i=0; i<n; i++)
  19.         {
  20.         int position=i;
  21.         for(int j=i+1; j<=n; j++)
  22.             {
  23.            
  24.             if (values[position]>values[j])
  25.                 position=j;
  26.             }
  27.         if (position!=i)
  28.             {
  29.             int swap= values[i];
  30.             values[i]=values[position];
  31.             values[position]=swap;
  32.                
  33.             }
  34.         }
  35.     return;
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement