冒泡排序:#include<stdio.h>
void maoPao(int arr[],int length);
{
int temp;
for(int i=0;i<length-1;i++){
for(int j=0;j<length-i-1;j++){
if(arr[j]>arr[j+1]){
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
int main(){
int a[10]={1,200,23,45,12,34,19,4,388,63};
maoPao(a,10);
for(int i=0;i<10;i++){
printf("%d\t",a[i]);
}
return 0;
} |
|