#include <stdio.h>
#define INT "%d\n"
void bubbleSort(int *arr,int size);
int main()
{
int a[] = {6,2,9,1,100,23,3,89,45};
int size = sizeof(a)/sizeof(a[0]);
bubbleSort(a,size);
for (int i=0;i<size;i++){
printf(INT,a[i]);
}
return 0;
}
void bubbleSort(int *arr,int size){
int tmp = 0;
for (int i=0;i<size;i++){
for (int j=0;j<size-i;j++){
if(arr[j] > arr[j+1]){
tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
}
}
}
网友评论