Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created May 26, 2020 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/8573fe8fe92f444a4e2144efe6895031 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/8573fe8fe92f444a4e2144efe6895031 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdbool.h>
int main(){
int liste[] = {4, 3, 7, 5, 6};
int laenge = 5;
int i = 0;
int j, tauschwert;
bool beendet = false;
while (!beendet){
for (j = 0; j < laenge - i - 1; j++){
beendet = true;
if (liste[j] > liste[j + 1]){
tauschwert = liste[j];
liste[j] = liste[j + 1];
liste[j + 1] = tauschwert;
beendet = false;
}
}
printf("Durchgang %i: ", i + 1);
for (j = 0; j < laenge; j++){
printf("%i ", liste[j]);
}
printf("\n");
i++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment