《几种排序法的头文件》由会员分享,可在线阅读,更多相关《几种排序法的头文件(3页珍藏版)》请在金锄头文库上搜索。
typedef structKeyType key;DataType;void InsertSort(DataType a,int n)/直接插入排序int i,j;DataType temp;for(i=0;i-1&temp.key-1&temp.keyaj+1.key)flag=1;temp=aj;aj=aj+1;aj+1=temp;void QuickSort(DataType a,int low,int high)/快速排序int i=low,j=high;DataType temp=alow;while(ij)while(ij&temp.key=aj.key)j-;if(ij)ai=aj;i+;while(ij&ai.keytemp.key)i+;if(ij)aj=ai;j-;ai=temp;if(lowi)QuickSort(a,low,i-1);if(ihigh)QuickSort(a,j+1,high);