Created
January 26, 2018 20:55
-
-
Save tuxcuiabano/1a29331b9f0f4c33a6c741fd70a4beb9 to your computer and use it in GitHub Desktop.
Implementação do Insertion Sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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