快速排序程式

2022-05-04 13:51:12 字數 717 閱讀 6840

快速排序程式

#include int findpos(int * a,int low, int

high);

void quicksort(int * a, int low, int

high);

intmain()

; //

此處可以多試幾組資料

inti;

quicksort(a,

0, 5);//

第二個引數表示第乙個元素的下標, 第三引數表示最後乙個元素的下標

for(i=0;i<6;i++)

printf(

"%d

", a[i]);

printf("\n

");return0;

}void quicksort(int * a, int low, int

high)

}int findpos(int * a,int low, int

high) //

終止while迴圈後low和high一定是相等的

a[low] = val;//

此時a[low] = a[high]

return low; //

low可以改為high,但不可以改為val ,但不能改為a[low],也不能改為a[high];

}

排序和查詢的關係

查詢是排序的前提

排序是重點

快速排序程式(windows vs)

sort and count.cpp 定義控制台應用程式的入口點。pragma once include stdafx.h include include include include using namespace std int filelength 100000 int numbers 10...

拓撲排序程式

拓撲排序 include include define max vertex num 50 define stack size 50 typedef struct arcnodearcnode 鄰接表結點 typedef struct vnodevnode,adjlist max vertex nu...

演算法 「氣泡排序」程式模擬

文獻 data structures and algorithms using c michael mcmillan 平台 net 2.0 排序最基礎最基本的演算法便是氣泡排序了,bubble sort,最基本的往往最能反映排序的基本思想,基本思路,儘管它做了很多次冗餘的比較。在.net中通過ran...