Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- int cmp(const void* a, const void *b) { return (*(const int*)a)-(*(const int*)b); }
- int main()
- {
- const int N = 4;
- int i;
- int input[] = { 4, 3, 2, 1 };
- int aux[2*N];
- for(i = 0; i < N; ++i) { aux[2*i] = input[i]; aux[2*i+1] = i; }
- qsort(aux, N, sizeof(int)*2, cmp);
- for(i = 0; i < N; ++i) { printf("%d ", aux[2*i + 1]); }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment