+ 1
Why? what happens?
Why the function sort() does not work as expected to? What happens during the execution of the code? How can we fix this bug? .... static void sort(int[] arr) { int a = 0; for(int i : arr) { int b = 0; for(int j : arr) { if(i > j) { arr[a] = j; arr[b] = i; } b++; } a++; } } .... https://code.sololearn.com/ceMAVa9M15fM/?ref=app
1 Respuesta
0
You are missing a temporary variable to save the value of the old position for the new position. That is why the final values are repeated