fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int comparador(const void *a, const void *b) {
  5. return ( *(int*)a - *(int*)b );
  6. }
  7.  
  8. int main () {
  9. int i, val[] = { 15, 30, 10, 20, 25 };
  10.  
  11. //ordena o array
  12. qsort(val, 5, sizeof(int), comparador);
  13.  
  14. //mostra os valores do array
  15. for( i = 0 ; i < 5; i++ ) {
  16. printf("%i ", val[i]);
  17. }
  18.  
  19. return(0);
  20. }
  21.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
10 15 20 25 30