Skip to content

Instantly share code, notes, and snippets.

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