Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created May 26, 2020 06:30
Show Gist options
  • Save BMU-Verlag/bb4d361a03defb5bee11a9081db41435 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/bb4d361a03defb5bee11a9081db41435 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(){
int liste[] = {6, 4, 7, 5, 3};
int laenge = 5;
int i, j, tauschwert;
for (i = 0; i < laenge - 1; i++){
for (j = 0; j < laenge - i - 1; j++){
if (liste[j] > liste[j + 1]){
tauschwert = liste[j];
liste[j] = liste[j + 1];
liste[j + 1] = tauschwert;
}
}
printf("Durchgang %i: ", i + 1);
for (j = 0; j < laenge; j++){
printf("%i ", liste[j]);
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment