maopo&nihuanxu

void huanshunxu(int *arr,int len)

{

int i =0;

int j =len-1;

while (i<j) {

int temp;

temp=arr[i];

arr[i]=arr[j];

arr[j]=temp;

i++;

j--;

}

for (int i= 0; i<len; i++) {

printf("%-4d ",arr[i]);

}

printf("\n");

};

void maopo(int *arr,int len)

{

for (int i =0; i<len-1; i++) {

for (int j =0; j<len-1-i; j++) {

if (arr[j]>arr[j+1]) {

int temp;

temp=arr[j];

arr[j]=arr[j+1];

arr[j+1]=temp;

}

}

}

for (int i =0; i<len; i++) {

printf("%-4d",arr[i]);

}

printf("\n");

}

时间: 2024-12-12 03:06:09

maopo&nihuanxu的相关文章