【发布时间】:2013-09-01 06:06:09
【问题描述】:
我的程序使用选择排序处理比较次数。它返回错误的组合数。 comp哪里出了问题?
我的演示:
ArrayI[] ints = new ArrayI[5];
ints[0] = new ArrayInts(3);
ints[1] = new ArrayInts(9);
ints[2] = new ArrayInts(6);
ints[3] = new ArrayInts(1);
ints[4] = new ArrayInts(2);
SelectionSort.selectionSort(myInts);
System.out.println(" ");
System.out.println("Sorted array: ");
for(ArrayI ints:myInts){
System.out.println(ints);
}
System.out.println(" ");
System.out.println("Number of comparisons: " + SelectionSort2.selectionSort2(ints));
【问题讨论】:
-
为什么你有不同的计算比较次数的方法?你不能用第一种方法本身来做吗?
-
ArrayInts类的意义何在?为什么不能简单地使用Integer? -
@seh 不是重复的 - 这些问题与两种不同的排序方法有关。
-
啊,你是对的。我看到每个作者都是同一个作者,还以为他发了两次。我撤回了那票。我会出于不同的原因投票关闭它。