Binary search: Difference between revisions

m
→‎{{header|C}}: In main program, the case "is not found" extracted.
m (→‎{{header|C}}: In main program, the case "is not found" extracted.)
Line 1,698:
int x = 2;
int i = bsearch(a, n, x);
printfif ("%di is>= at0) index %d\n", x, i);
printf("%d is at index %d\n", x, i);
else
printf("%d is not found\n", x);
x = 5;
i = bsearch_r(a, x, 0, n - 1);
printfif ("%di is>= at0) index %d\n", x, i);
printf("%d is at index %d\n", x, i);
else
printf("%d is not found\n", x);
return 0;
}
Line 1,708 ⟶ 1,714:
<pre>
2 is at index 4
5 is atnot index -1found
</pre>
 
Anonymous user