改成:
public class TicTacToe
{
public static void main(String[] args)
{
int[] a = {4,3,2,1};
for (int i=0; i<4; i++)
System.out.print(a[i]+" ");
System.out.println("\n"); new Isort(a,4); for (int i=0; i<4; i++)
System.out.print(a[i]+" ");
System.out.println();
}
}class Isort
{
public Isort(int[] a, int n)
{
for (int i=1; i<n; i++)
{ int j=i;
int k=a[i];
while((j>0) && (a[j-1]>k))
{
a[j]=a[j-1];
j--;
}
}
//a[j]=k;
}
}------------------
此程序不光是语法的问题,设计上也存在很大的问题
public class TicTacToe
{
public static void main(String[] args)
{
int[] a = {4,3,2,1};
for (int i=0; i<4; i++)
System.out.print(a[i]+" ");
System.out.println("\n"); new Isort(a,4); for (int i=0; i<4; i++)
System.out.print(a[i]+" ");
System.out.println();
}
}class Isort
{
public Isort(int[] a, int n)
{
for (int i=1; i<n; i++)
{ int j=i;
int k=a[i];
while((j>0) && (a[j-1]>k))
{
a[j]=a[j-1];
j--;
}
}
//a[j]=k;
}
}------------------
此程序不光是语法的问题,设计上也存在很大的问题
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货