InsertionSort in C3PO implementiert
parent
e90209a20d
commit
8396f15947
|
@ -22,8 +22,19 @@ public class C3PO extends Roboter{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] think(int[] zahlen) throws RobotException {
|
public int[] think(int[] zahlen) throws RobotException {
|
||||||
// TODO Auto-generated method stub
|
int remember;
|
||||||
return null;
|
|
||||||
|
for (int i = 1; i < zahlen.length; i++) {
|
||||||
|
remember = zahlen[i];
|
||||||
|
int k = i;
|
||||||
|
|
||||||
|
while (k > 0 && zahlen[k - 1] < remember) {
|
||||||
|
zahlen[k] = zahlen[k - 1];
|
||||||
|
k--;
|
||||||
|
}
|
||||||
|
zahlen[k] = remember;
|
||||||
|
}
|
||||||
|
return zahlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue