以下是引用suifengjita在2006-11-5 10:49:11的发言:
#include<stdio.h>
int main()
{
int a,i,j,k,m,n,w;
int g[]={3,4,5,7,6,9,8,2,1,10}; --->少了;号
for(i=1;i<=9;++i)
{
g[0]=g[i];
j=1;n=i-1;
while(j<=n)
{m=(j+n)/2;
if(k<g[m])
n=m-1;
else
j=m+1;
}
for(a=i-1;a=j+1;++a)
g[a+1]=g[a];
g[j+1]=g[0];
}
for(w=0;w<=9;++w)
printf("%d ",g[w]);
}