Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.    int array[100], n, c, d, position, swap;
  5.    printf("how many ints\n");
  6.    scanf("%d", &n);
  7.    printf("type %d ints\n", n);
  8.    for ( c = 0 ; c < n ; c++ )
  9.       scanf("%d", &array[c]);
  10.    for ( c = 0 ; c < ( n - 1 ) ; c++ )
  11.    {
  12.       position = c;
  13.       for ( d = c + 1 ; d < n ; d++ )
  14.       {
  15.          if ( array[position] > array[d] )
  16.             position = d;
  17.       }
  18.       if ( position != c )
  19.       {
  20.          swap = array[c];
  21.          array[c] = array[position];
  22.          array[position] = swap;
  23.       }
  24.    }
  25.    for ( c = 0 ; c < n ; c++ )
  26.       printf("%d\n", array[c]);
  27.    return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement