Last active
March 23, 2016 09:22
-
-
Save CindyLinz/c88ecdf54794c1f02ab5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(){ | |
int value[] = {2,5,4,3,8,7,9,1,10,6}; | |
int index[] = {0,1,2,3,4,5,6,7,8,9}; | |
int cmp(const void * a, const void * b){ | |
return value[*(int*)a] - value[*(int*)b]; | |
} | |
qsort(index, 10, sizeof(int), cmp); | |
for(int i=0; i<10; ++i) | |
printf("%d ", value[index[i]]); | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment