Guess the number/With feedback (player): Difference between revisions

Content added Content deleted
Line 169: Line 169:
Awwwright</pre>
Awwwright</pre>


----
A hacky solution using <tt>bsearch()</tt> and pointers to represent integers. Although the pointers do not point to valid things, <tt>bsearch()</tt> doesn't actually dereference the pointers or care what they point to; it just passes them to the comparator and searches the space of pointers. We can use that to search any space of integers.

The following is a hacky solution using <tt>bsearch()</tt> and pointers to represent integers. Although the pointers do not point to valid things, <tt>bsearch()</tt> doesn't actually dereference the pointers or care what they point to; it just passes them to the comparator and searches the space of pointers. We can use that to search any space of integers.
{{trans|Java}}
{{trans|Java}}
<lang c>#include <stdio.h>
<lang c>#include <stdio.h>