代码效果
递归代码内容
void OrderTurnNumber(int* arr, int overflow, int sz) { if (overflow < sz - 1) { if (*arr > *(arr 1)) { int tmp = *arr; *arr = *(arr 1); *(arr 1) = tmp; if (overflow > 0) { OrderTurnNumber(arr - 1, overflow - 1,sz); } } OrderTurnNumber(arr 1, overflow 1,sz); } } int main() { int arr[] = { 5,7,7,6,5,4,7,6,1,1,2,3,54654,213213,21221,0,14,1,3,4,7,12,1,2,5,52,165,46,4,654,55,3564}; int sz = sizeof(arr) / sizeof(arr[0]); OrderTurnNumber(arr,0,sz); for (int i = 0; i < sz; i ) printf("%d ", arr[i]); return 0; }
我也去问了别人,我建议是用正常的算法去做这个东西....