下面是我家了一点格式控制和输出语句后的结果,应该是你需要的吧!Data items in original order:
27 6 4 8 10 12 89 68 45 37
Data dealing order:
6 27 4 8 10 12 89 68 45 37
4 6 27 8 10 12 89 68 45 37
4 6 8 27 10 12 89 68 45 37
4 6 8 10 27 12 89 68 45 37
4 6 8 10 12 27 89 68 45 37
4 6 8 10 12 27 89 68 45 37
4 6 8 10 12 27 68 89 45 37
4 6 8 10 12 27 45 68 89 37
4 6 8 10 12 27 37 45 68 89
Data items in ascending order:
4 6 8 10 12 27 37 45 68 89
27 6 4 8 10 12 89 68 45 37
Data dealing order:
6 27 4 8 10 12 89 68 45 37
4 6 27 8 10 12 89 68 45 37
4 6 8 27 10 12 89 68 45 37
4 6 8 10 27 12 89 68 45 37
4 6 8 10 12 27 89 68 45 37
4 6 8 10 12 27 89 68 45 37
4 6 8 10 12 27 68 89 45 37
4 6 8 10 12 27 45 68 89 37
4 6 8 10 12 27 37 45 68 89
Data items in ascending order:
4 6 8 10 12 27 37 45 68 89
解决方案 »
- web程序servlet如何多线程?
- ireport 中文 pdf 问题 当文字后面加CC的时候是正常的,当加MM在pdf 里显示就换行了 请问怎么解决
- 大家都用什么报表软件?
- 请教高手为什么异地使用花生壳连不上数据库
- 这个是什么错误 mysql tomcat 开网站报错
- myeclipse for linux 下载地址,谁给个?
- struts2.0配置的问题
- [有效性验证]STRUTS可否直接用JS文件而不用validator
- 请教 connection与result与statement问题
- 帮忙,struts传递参数问题?
- 郁闷啊。辞职了,放分了
- Java Core卷1看完,想往J2EE方向发展,卷2还用看吗?请推荐下一步要看的书。
Data items in original order:
27
6
4
8
10
12
89
68
45
37
6
27
4
8
10
12
89
68
45
37
4
6
27
8
10
12
89
68
45
37
4
6
8
27
10
12
89
68
45
37
4
6
8
10
27
12
89
68
45
37
4
6
8
10
12
27
89
68
45
37
4
6
8
10
12
27
89
68
45
37
4
6
8
10
12
27
68
89
45
37
4
6
8
10
12
27
45
68
89
37
4
6
8
10
12
27
37
45
68
89
Data items in ascending order:
4
6
8
10
12
27
37
45
68
89
public class InsertSort
{
public static void main(String arg[])
{
//定义一个整型数组
int a[]={27,6,4,8,10,12,89,68,45,37};
System.out.println("Data items in original order:");
//调用pringArray方法打印数组元素
printArray(a);
//调用sortInsert方法对数组进行排序,从小到大
sortInsert(a);
System.out.println("Data items in ascending order:");
//显示排序后的数组元素
printArray(a);
}
public static void sortInsert(int a[]){
int hold,pass,i;
//下面的算法是冒泡算法,用于排序
for(pass=1;pass<a.length;pass++)
{
hold=a[pass];
for(i=pass-1;i>=0;i--)
if(a[i]>hold)
a[i+1]=a[i];
else
break;
a[i+1]=hold;
printArray(a);
}
}
public static void printArray(int b[])
{
for(int i=0;i<b.length;i++)
System.out.println(""+b[i]);
System.out.println("");
}
}