Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int ordena(const void *a, const void *b);
- int main(int argc, char** argv)
- {
- int teste, num;
- scanf("%d", &teste);
- for(int i = 0; i < teste; i++)
- {
- scanf("%d", &num);
- int vetor[num];
- for(int j = 0; j < num; j++)
- {
- scanf("%d", &vetor[j]);
- }
- qsort(vetor, num, sizeof(int), ordena);
- for(int j = 0; j < num; j++)
- {
- printf("%d ", vetor[j]);
- }
- printf("n");
- }
- return 0;
- }
- int ordena(const void *a, const void *b)
- {
- if(*(int*)a == *(int*)b)
- return 0;
- else if(*(int*)a < * (int*)b)
- return -1;
- else
- return 1;
- }
Add Comment
Please, Sign In to add comment