R2D2 Sortieralgorithmus angepasst
parent
dabe1dda0f
commit
42d4f44e02
|
@ -57,16 +57,16 @@ public class R2D2 implements Robot {
|
|||
}
|
||||
@Override
|
||||
public int[] think(int[] zahlen) throws RobotException {
|
||||
int n = zahlen.length;
|
||||
for (int i = 1; i < n; ++i) {
|
||||
int key = zahlen[i];
|
||||
int j = i - 1;
|
||||
while (j >= 0 && zahlen[j] > key) {
|
||||
zahlen[j + 1] = zahlen[j];
|
||||
j = j - 1;
|
||||
for (int i = 0; i < zahlen.length - 1; i++) {
|
||||
for (int j = i + 1; j < zahlen.length; j++) {
|
||||
if (zahlen[i] > zahlen[j]) {
|
||||
int temp = zahlen[i];
|
||||
zahlen[i] = zahlen[j];
|
||||
zahlen[j] = temp;
|
||||
}
|
||||
}
|
||||
zahlen[j + 1] = key;
|
||||
}
|
||||
|
||||
return zahlen;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue