private int temp,i,j;
private void sort(int []a)
{
int n = a.length;
for(int d=n/2;d>=1;d=d/2)
{
for(i=d;i<n;i++)
{
temp = a[i];
for(j=i-d;j>=0&&temp<a[j];j=j-d)
{
a[j+d] = a[j];
}
a[j+d] = temp;
}
}
for(int i:a)
System.out.print(i+" ");
} public void print(int []a)
{
sort(a);
} 这代码是什么意思?那个大狭来个注释!!!谢谢!!!
private void sort(int []a)
{
int n = a.length;
for(int d=n/2;d>=1;d=d/2)
{
for(i=d;i<n;i++)
{
temp = a[i];
for(j=i-d;j>=0&&temp<a[j];j=j-d)
{
a[j+d] = a[j];
}
a[j+d] = temp;
}
}
for(int i:a)
System.out.print(i+" ");
} public void print(int []a)
{
sort(a);
} 这代码是什么意思?那个大狭来个注释!!!谢谢!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货