示例:
我的排序代碼
#includeint split(int a[], int low, int high)
{int tmp = a[low];
a[low] = 0;
while (low != high)
{if (a[low] == 0)
{ while (low != high)
{ if (a[high]< tmp)
{a[low] = a[high];
a[high] = 0;
low++;
break;
}
high--;
}
}
if (a[high] == 0)
{ while (low!=high)
{ if(a[low]>tmp)
{a[high] = a[low];
a[low] = 0;
high--;
break;
}
low++;
}
}
}
a[low] = tmp;
return low;
}
void quicksort(int a[], int low, int high)
{if (low >= high)
return;
int mid = split(a, low, high);
quicksort(a, low, mid - 1);
quicksort(a, mid + 1, high);
}
int main()
{int a[] = {9,16,47,82,4,66,12,3,25,51 };
quicksort(a, 0, 9);
for(int i=0;i<10;i++)
{printf("%d ", a[i]);
}
return 0;
}
你是否還在尋找穩(wěn)定的海外服務器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調度確保服務器高可用性,企業(yè)級服務器適合批量采購,新人活動首月15元起,快前往官網查看詳情吧
網站題目:細思c語言之《c語言程序-創(chuàng)新互聯(lián)
標題路徑:http://chinadenli.net/article38/dhispp.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供企業(yè)網站制作、手機網站建設、移動網站建設、做網站、網站營銷、動態(tài)網站
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)