Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 7
- void bubbleSort(int *A, int length)
- {
- int i, j;
- for(i = 1; i <= length - 1; i++)
- {
- for(j = 0; j < length - i; j++)
- if(A[j] > A[j + 1])
- {
- int temp = A[j];
- A[j] = A[j + 1];
- A[j + 1] = temp;
- }
- }
- }
- int main()
- {
- int arr[SIZE] = {11, 1, 8, 5, 6, 8, 4};
- int i;
- bubbleSort(arr, SIZE);
- for(i = 0; i < SIZE; i++)
- printf("%d ", arr[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement