0
我在学习循环排序并弄糊涂了为什么循环排序的外循环运行(n-1)次而不是n次。 (n是数组大小)循环排序:为什么最外面的循环运行(n-1)次
for (int cycle_start=0; cycle_start< n-1; cycle_start++)
请解释一下。谢谢
我在学习循环排序并弄糊涂了为什么循环排序的外循环运行(n-1)次而不是n次。 (n是数组大小)循环排序:为什么最外面的循环运行(n-1)次
for (int cycle_start=0; cycle_start< n-1; cycle_start++)
请解释一下。谢谢
在循环排序中,最后一个项目会自动在正确的位置,所以你不需要循环。
Thanks @Dancrumb – user5005768