Advertisement
Guest User

ordenacao-vetor-print-menor-maior

a guest
May 23rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  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, 12, 11, 25, 40, 5 };
  10.  
  11.    qsort(val, 10, sizeof(int), comparador);
  12.  
  13.    printf("Menor valor: %i\nMaior valor: %i\n", val[0], val[9]);
  14.    
  15.    return(0);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement