This is the instruction in one of the exercises in our Java class. Before anything else, I would like to say that I \'do my homework\' and I\'m not just being lazy asking someon
int x[] = { 10, 30, 15, 69, 52, 89, 5 };
int max, temp = 0, index = 0;
for (int i = 0; i < x.length; i++) {
int counter = 0;
max = x[i];
for (int j = i + 1; j < x.length; j++) {
if (x[j] > max) {
max = x[j];
index = j;
counter++;
}
}
if (counter > 0) {
temp = x[index];
x[index] = x[i];
x[i] = temp;
}
}
for (int i = 0; i < x.length; i++) {
System.out.println(x[i]);
}