#include
int main(void) { int shuzu[] = {15,3,153,51571,51,53,5,5,16,5512,523152,156,365125,}; int max = shuzu[0]; long length = sizeof(shuzu)/sizeof(shuzu[0]); //找出最大值,并替换最右边 int b; for (b = length-1;b>0;b--) { int control; int max_location = 0; for ( control = 1;control <b+1;control++) { if (max < shuzu[control]) { max = shuzu[control]; max_location = control; } }
int t = shuzu[max_location];
shuzu[max_location] = shuzu[b];
shuzu[b] = t;
}
//遍历
for (int a = 0; a<length;a++) {
printf("%d\t",shuzu[a]);
}
return 0;
}