Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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