1、请设计直接插入排序算法、折半插入排序算法、希尔排序算法,输出每一趟的排序结果
2、源码
#include <stdio.h>
#define MaxSize 100
typedef int KeyType;
typedef char ElemType;
typedef struct{
KeyType key;
ElemType data;
} SqType;
//********直接插入排序****************
void InsertSort(SqType R[] ,int n){
int i,j;
SqType tmp;
for(i=1;i<n;i++){
if(R[i-1].key > R[i].key){
tmp=R[i];
j=i-1;
do{
R[j+1]=R[j];
j--;
} while(j>=0 && R[j].key>tmp.key);
R[j+1] = tmp;
}
printf("i=%d ",i);
for(int a=0;a<n;a++)
printf("%3d",R[a].key);
printf("\n");
}
}
//********折半插入排序****************
void BinInsertSort(SqType R[],int n){
int i,j,low,high,mid;
SqType tmp;
for(i=1;i<n;i++){
if(R[i-1].key>R[i].key){
tmp=R[i];
low=0;
high=i-1;
while(low<=high){
mid&#