//楼主,我们更想看思路,关于这代码,网上百度很多!我自己也写了个
#include <stdio.h>
int main()
{
int array[] = {12, 8, 4, 11, 5, 20, 1};
int length = sizeof(array)/sizeof(int);
for (int i = 0; i < length; i++) {
for (int j = i+1; j < length; j++) {
int temp;
if (array[j] < array[i] ) {
temp = array[j];
array[j] = array[i];
array[i] = temp;
}
}
printf("%d\t", array[i]);
}
return 0;
} |