#include <stdio.h>
#include <stdlib.h>
int array1[] = {1, 7, 3, 9, 5};
double array2[] = {1.1, 7.7, 3.3, 9.9, 5.5};
int compare (const void * a, const void * b) {
double diff = array2[*(int*)a] - array2[*(int*)b];
return (0 < diff) - (diff < 0);
}
int main(void) {
int perm[5], i;
int res[5];
for (i = 0 ; i != 5 ; i++) {
perm[i] = i;
}
qsort (perm
, 5, sizeof(int), compare
); for (i = 0 ; i != 5 ; i++) {
res[i] = array1[perm[i]];
}
for (i = 0 ; i != 5 ; i++) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCiAgICBpbnQgYXJyYXkxW10gPSB7MSwgNywgMywgOSwgNX07CiAgICBkb3VibGUgYXJyYXkyW10gPSB7MS4xLCA3LjcsIDMuMywgOS45LCA1LjV9OwoKICAgIGludCBjb21wYXJlIChjb25zdCB2b2lkICogYSwgY29uc3Qgdm9pZCAqIGIpIHsKICAgICAgICBkb3VibGUgZGlmZiA9IGFycmF5MlsqKGludCopYV0gLSBhcnJheTJbKihpbnQqKWJdOwogICAgICAgIHJldHVybiAgKDAgPCBkaWZmKSAtIChkaWZmIDwgMCk7CiAgICB9CgogICAgaW50IG1haW4odm9pZCkgewogICAgICAgIGludCBwZXJtWzVdLCBpOwogICAgICAgIGludCByZXNbNV07CiAgICAgICAgZm9yIChpID0gMCA7IGkgIT0gNSA7IGkrKykgewogICAgICAgICAgICBwZXJtW2ldID0gaTsKICAgICAgICB9CiAgICAgICAgcXNvcnQgKHBlcm0sIDUsIHNpemVvZihpbnQpLCBjb21wYXJlKTsKICAgICAgICBmb3IgKGkgPSAwIDsgaSAhPSA1IDsgaSsrKSB7CiAgICAgICAgICAgIHJlc1tpXSA9IGFycmF5MVtwZXJtW2ldXTsKICAgICAgICB9CiAgICAgICAgZm9yIChpID0gMCA7IGkgIT0gNSA7IGkrKykgewogICAgICAgICAgICBwcmludGYoIiVkXG4iLCByZXNbaV0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gMDsKICAgIH0=