Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

  • Autor


package paket;


public class Quickdort1 {


    public static void main(String[] args) {


        int[] liste = { 0, 9, 4, 6, 2, 8, 5, 1, 10 };

        System.out.println("Vor dem sortieren: ");

        for (int i = 0; i < liste.length; i++) {

            System.out.print(liste[i] + " ");

        }


        teilen(liste, 0, liste.length - 1);


        System.out.println("Nach dem sortieren: ");

        for (int i = 0; i < liste.length; i++)

            System.out.print(liste[i] + " ");

    }


    public static int teilen(int list[], int links, int rechts) {

        int i = links;

        int j = rechts - 1;

        int pivot = list[rechts];

        int t = 0;

        int p = 0;


        while (true) {

            while (list[i] <= pivot && i < rechts) {

                i = i + 1;

            }

            while (list[j] >= pivot && j > links) {

                j = j - 1;

            }


            if (i > j) {

                t = list[i];

                list[i] = list[j];

                list[j] = t;

            }

            while (i < j) {

                if (list[i] > pivot) {

                    p = list[i];

                    list[i] = list[rechts];

                    list[rechts] = p;


                }

            }

        }


    }

}

<Vielleicht hilft das weiter...

ich bekomme hier nur vor dem sortieren raus, nach dem sortieren wird einfach nicht mehr angezeigt

Was heißt: "wird nicht mehr angezeigt"?

Beendet das Programm ohne weitere Ausgabe?

Hängt das Programm in einer Endlosschleife?

Bricht es mit einer Fehlermeldung ab?

Bevor ich mir auch nur die Mühe mache mich durch deinen unkomentierten Code zu wühlen will ich zumindest mal wissen, nach was für einem Problem du genau suchst.

Hier noch ein Tipp aufs Offensichtliche: Es gibt einen Grund, warum man "while (true)" wann immer es geht vermeiden sollte...

Leider funktioniert es damit auch nicht :(
Nein, natürlich nicht. Die Stelle, die du mit ??? markiert hast, ist nämlich nicht die einzige fehlerhafte.

Da steht auch noch zwei Mal "ende" im Pseudocode, vermutlich ein unbedingter Sprung ("goto"). Das fehlt bei deiner Umsetzung.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.