C: qsort
From AdonaiMedrado.Pro.Br
Revision as of 01:49, 17 April 2009 by Adonaimedrado (Talk | contribs) (New page: <code lang="c"> #include <stdio.h> #define TAMANHO_VETOR 10 int comparar(void *a, void *b) { return *(int *)a-*(int *)b; } int main(void) { int i, v[TAMANHO_VETOR]; for(i=0;i<TAMANHO_...)
#include <stdio.h> #define TAMANHO_VETOR 10 int comparar(void *a, void *b) { return *(int *)a-*(int *)b; } int main(void) { int i, v[TAMANHO_VETOR]; for(i=0;i<TAMANHO_VETOR;i++) scanf("%d",v+i); qsort(v,TAMANHO_VETOR,sizeof(int),comparar); for(i=0;i<TAMANHO_VETOR;i++) printf("%d ",*(v+i)); printf("\n"); }