这是我的家庭作业的链接。
http://courses.cs.purdue.edu/cs18000:fall13:hw13
我更喜欢解释而不是实际回答问题的代码,以便我可以学习。我现在的代码是这样的。
public class Sorter {
double[] x = { 42.0, 3.5, Math.PI, 12.2, -47 };
double[] y = { 0, 0, 0, 0, 0};
public void copyOf() {
for (int i = 0; i < x.length; i++)
x[i] = y[i];
}
public void sort() {
for (int a = y.length; a >= 0; a -= 1) {
if (y[a] < y[0]) {
int b = 0;
y[0] = b;
y[a] = y[0];
y[a] = b;
}
if (y[a] < y[1]) {
int b = 0;
y[1] = b;
y[a] = y[1];
y[a] = b;
}
if (y[a] < y[2]) {
int b = 0;
y[2] = b;
y[a] = y[2];
y[a] = b;
}
if (y[a] < y[3]) {
int b = 0;
y[3] = b;
y[a] = y[3];
y[a] = b;
}
if (y[a] < y[4]) {
int b = 0;
y[4] = b;
y[a] = y[4];
y[a] = b;
}
}
}
}