我的程序使用选择排序处理比较次数。它返回错误的组合数。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));