Sie sind auf Seite 1von 1

Ueb3_2 Sortierung

Deklarationen
int ganz[10];

// 10 Ganzzahlen in Feld einlesen:

for (int i=0; i<10; i++)

cout << "Ganzzahl: ";

cin >> ganz[i];

Probeausgabe

// Sortierung:

fertig  false

solange Sortierung nicht fertig


while (!fertig)

fertig=true; // auf Verdacht

Schleife über alle Nachbarpaare, also über 9 Paare

if (ganz[i]>ganz[i+1])
T F

fertig=false; // leider doch nicht fertig

Inhalte von ganz[i] und ganz[i+1] tauschen

Rückwärtsausgabe des sortierten Feldes ganz

Das könnte Ihnen auch gefallen