From 818f0d3787f0c8d240035a2d4d0a73a87ffeb576 Mon Sep 17 00:00:00 2001 From: cedri Date: Sat, 7 Jan 2023 20:27:24 +0100 Subject: [PATCH] Absteigende Sortierung implementiert --- Robbie-Management-System/src/domain/C3PO.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Robbie-Management-System/src/domain/C3PO.java b/Robbie-Management-System/src/domain/C3PO.java index e51694f..8c78c74 100644 --- a/Robbie-Management-System/src/domain/C3PO.java +++ b/Robbie-Management-System/src/domain/C3PO.java @@ -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; } }