좋아, 나는 그 문제를 오해하고 있었다. 그것을 읽은 후 두 번 나는 randInt
실제로 배열 자체를 채우는 데 사용하는 방법입니다. 그래서 randInt
을 호출 할 때 재귀 호출이라고 생각합니다. 이것은 어쨌든 다음과 같이 보여야합니다 :배열의 참조를 바꾸기
static int[] randInt(int i, int j) {
int[] temp = new int[(j - i) + 1];
for (i = 0; i < j; i++) {
temp[i] = i + 1; // here i populate the array
}
System.out.println(Arrays.toString(temp)); // this prints [1, 2, 3, 4, 5]
for (i = 1; i < j;i++){
swapReferences(temp[i], temp[randInt(0,i)]); //this is some sort of recursive call that swaps the references
// btw that statement does not compile, how can i pass a method as a parameter?
}
return temp;
}
static void swapReferences(int a, int b) { //these parameters are wrong, need to be changed
//Method to swap references
}
죄송합니다.하지만 나는 그것이 올바르게되어야한다고 생각합니다.
@SotiriosDelimanolis되지는 다른 문제를 교환 할 수 있습니다. – user1404664
당신은 그렇게 생각할 것입니다, 그러나 당신은 틀릴 것입니다. –
다른 _scenario_, 같은 문제가 발생했습니다. – csmckelvey