- #include <stdio.h>
- void printArr(int arr[],int length){
- int i;
- for(i=0;i<length;i++){
- printf("%d,",arr[i]);
- }
- printf("\n");
- }
- void bubble(int arr[],int length){
- int i,j;
- for(i=1;i<length;i++){
- for(j=0;j<length-i;j++){
- int temp;
- if(arr[j] > arr[j+1]){
- temp = arr[j];
- arr[j] = arr[j+1];
- arr[j+1] = temp;
- }
- }
- }
- printArr(arr,length);
- }
- int main(void){
- int arr[10] = {2,3,2,6,1,87,1,78,2,3};
- printArr(arr,10);
- bubble(arr,10);
- }