问题描述
为什么我们不能通过这个修改就避免lomuto分区中的最终swap语句?
set Cap to (do shell script "ioreg -w0 -l | grep ExternalChargeCapable")
tell Cap to set {wallPower} to {last word of paragraph 1}
if wallPower = "Yes" then
return 0
else
set Pct to (do shell script "pmset -g batt | grep -Eo \"\\d+%\" | cut -d% -f1")
if Pct ≤ 10 then
display notification "Batterij 10%. Meteen opladen." with title "Batterij bijna leeg!" sound name "Sosumi"
## delay 300
## say "Batterij 10%. Meteen opladen."
end if
end if
我的代码正确吗?
解决方法
这是正确的!。 排序有两种类型:稳定排序和不稳定排序。快速排序是一种不稳定的排序,因为在快速排序的分区过程中元素的相对位置会发生变化。如果我们使用以下代码(
int pivot=arr[h];
int i=l-1;
for(int j=l;j<=h;j++){
if(arr[j]<=pivot){
i++;
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
return i;
}