int main(int argc, const char * argv[]) { @autoreleasepool { int array[] = {3,2, 6, 9, 8, 5, 7, 1, 4}; //为了添加可移植性(採取sizeof())计算数组元素个数count int count = sizeof(array) /sizeof(array[0]); for (int i =1; iarray[j-1]如果大于 while会一直执行 直到0 然后跳出循环
while (j>0&&temp>array[j-1]) {
array[j] = array[j-1];
j--;
}
array[j] = temp;
}
for (int i = 0; i < count; i++) {
printf("[%2d]: %d\n", i, array[i]);
}
}
return 0;
}