Skip to content

Instantly share code, notes, and snippets.

@tuxcuiabano
Created January 26, 2018 20:55
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 tuxcuiabano/1a29331b9f0f4c33a6c741fd70a4beb9 to your computer and use it in GitHub Desktop.
Save tuxcuiabano/1a29331b9f0f4c33a6c741fd70a4beb9 to your computer and use it in GitHub Desktop.
Implementação do Insertion Sort
#include <stdio.h>
void insertS(int *V, int N){
int z,i,j,aux;
for(i=1;i<N;i++){
aux= V[i];
for(j=i;(j>0) && (aux<V[j-1]);j--)
V[j] = V[j-1];
V[j]=aux;
for(z=0;z<N;z++){
printf("%d ",V[z]);
}
printf("\n");
}
}
int main()
{
int V[] = {23,4,67,-8,90,54,21};
insertS(V,7);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment