/*来自课程实验*/
/*程序名:bsort.cpp*/
/*功能:实现数据的二分排序*/
#include
#include
void bsort(char *cp,int count)
{
int i,j,low,mid,high;
char t;
for(i=1;i
t=cp[i];
low=0;
high=i-1;
while(low<=high)
{
mid=(low+high)/2;
if(t
else
low=mid+1;
}
for(j=i-1;j>=low;j--)
cp[j+1]=cp[j];
cp[low]=t;
}
return;
}
void main()
{
char a[]={'k','k','x','a','w','f'};
int x=6;
bsort(a,x);
for(int i=0;i<6;i++)
putchar(a[i]);
getchar();
}