#include <stdio.h>
#include <stdlib.h>
int values[] = { 40, 10, 100, 90, 20, 25, 12, 13, 10, 40 };
int compare (const int *a, const int *b)
{
return *a - *b;
}
int main ()
{
int n;
for (n=0; n<10; n++)
{
printf("%d ",values[n]);
}
printf("\n");
qsort (values, 10, sizeof(int), compare);
for (n=0; n<10; n++)
{
printf ("%d ",values[n]);
}
printf("\n");
system("pause");
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCB2YWx1ZXNbXSA9IHsgNDAsIDEwLCAxMDAsIDkwLCAyMCwgMjUsIDEyLCAxMywgMTAsIDQwIH07CgppbnQgY29tcGFyZSAoY29uc3QgaW50ICphLCBjb25zdCBpbnQgKmIpCnsKICAgIHJldHVybiAqYSAgLSAqYjsgCn0KCmludCBtYWluICgpCnsKICAgIGludCBuOwogICAgZm9yIChuPTA7IG48MTA7IG4rKykKICAgIHsKICAgICAgICBwcmludGYoIiVkICIsdmFsdWVzW25dKTsKICAgIH0KICAgIHByaW50ZigiXG4iKTsKICAgIHFzb3J0ICh2YWx1ZXMsIDEwLCBzaXplb2YoaW50KSwgY29tcGFyZSk7CiAgICBmb3IgKG49MDsgbjwxMDsgbisrKQogICAgewogICAgICAgIHByaW50ZiAoIiVkICIsdmFsdWVzW25dKTsKICAgIH0KICAgIHByaW50ZigiXG4iKTsKICAgIHN5c3RlbSgicGF1c2UiKTsKICAgIHJldHVybiAwOwp9
prog.cpp: In function ‘int main()’:
prog.cpp:19: error: invalid conversion from ‘int (*)(const int*, const int*)’ to ‘int (*)(const void*, const void*)’
prog.cpp:19: error: initializing argument 4 of ‘void qsort(void*, size_t, size_t, int (*)(const void*, const void*))’
prog.cpp:25: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result