#include #include int compare_int(int *pi1, int *pi2) { int i1 = *pi1; int i2 = *pi2; return (i1 > i2)? 1 : ((i1 == i2)? 0 : -1); } int main(int argc, char * argv[]) { int t[] = {6, 2, 8, 6, 4, 8, 2, 9, 2, 1}; int i; int x = atoi(argv[1]); qsort(t, 10, sizeof(int), (int (*)(const void *, const void *))compare_int); printf("%s\n", bsearch(&x, t, 10, sizeof(int), (int (*)(const void *, const void *))compare_int)? "oui" : "non"); return EXIT_SUCCESS; }