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