R2D2 Selection Sort implementiert.

master
nikow 2023-01-03 17:50:14 +01:00
parent 8396f15947
commit c696e79cbf
1 changed files with 14 additions and 1 deletions

View File

@ -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