Absteigende Sortierung implementiert
parent
45b8f7b164
commit
818f0d3787
|
@ -15,8 +15,17 @@ public class C3PO extends Robotermodell implements Robot {
|
|||
|
||||
@Override
|
||||
public int[] think(int[] zahlen) throws RobotException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
for (int i = 0; i < zahlen.length - 1; i++) {
|
||||
int k = i;
|
||||
while (k >= 0 && zahlen[k] < zahlen[k+1]) {
|
||||
int zwischenspeicher = zahlen[k];
|
||||
zahlen[k] = zahlen[k+1];
|
||||
zahlen[k+1] = zwischenspeicher;
|
||||
k--;
|
||||
}
|
||||
}
|
||||
|
||||
return zahlen;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue