InsertionSort in C3PO implementiert
parent
e90209a20d
commit
8396f15947
|
@ -22,8 +22,19 @@ public class C3PO extends Roboter{
|
|||
|
||||
@Override
|
||||
public int[] think(int[] zahlen) throws RobotException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
int remember;
|
||||
|
||||
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