// 对数器
public class DataChecker {
// 创建一个随机数组
static int[] generateRandomArray() {
Random r = new Random();
int[] arr = new int[10];
for (int i = 0; i < arr.length; i++) {
arr[i] = r.nextInt(10);
}
return arr;
}
static void check() {
// 拷贝一份,后续做比较
int[] array = generateRandomArray();
int[] array2 = new int[array.length];
System.arraycopy(array,0,array2,0,array.length);
Arrays.sort(array);
SelectionSort.sort(array2);
boolean same = true;
for (int i = 0; i < array2.length; i++) {
if (array[i] != array2[i]) {
same = false;
}
}
System.out.println(same == true ? "right" : "wrong");
}
public static void main(String[] args) {
check();
}
}