Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int array[100], n, c, d, position, swap;
- printf("how many ints\n");
- scanf("%d", &n);
- printf("type %d ints\n", n);
- for ( c = 0 ; c < n ; c++ )
- scanf("%d", &array[c]);
- for ( c = 0 ; c < ( n - 1 ) ; c++ )
- {
- position = c;
- for ( d = c + 1 ; d < n ; d++ )
- {
- if ( array[position] > array[d] )
- position = d;
- }
- if ( position != c )
- {
- swap = array[c];
- array[c] = array[position];
- array[position] = swap;
- }
- }
- for ( c = 0 ; c < n ; c++ )
- printf("%d\n", array[c]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement