R2D2 Selection Sort implementiert.
parent
8396f15947
commit
c696e79cbf
|
@ -21,8 +21,21 @@ public class R2D2 extends Roboter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] think(int[] zahlen) throws RobotException {
|
public int[] think(int[] zahlen) throws RobotException {
|
||||||
|
int remember;
|
||||||
|
|
||||||
return null;
|
for (int i = 0; i < zahlen.length - 1; i++) {
|
||||||
|
int smallest = i;
|
||||||
|
|
||||||
|
for (int k = i+1; k < zahlen.length; k++) {
|
||||||
|
if (zahlen[i] < zahlen[smallest]) {
|
||||||
|
smallest = k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remember = zahlen[i];
|
||||||
|
zahlen[i] = zahlen[smallest];
|
||||||
|
zahlen[smallest] = remember;
|
||||||
|
}
|
||||||
|
return zahlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue