Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int high=100, low=1, guess=0, count=0;
- char answer;
- while( !count++ && printf("Choose a number [%d, %d] and I'll try to guess it\n", low, high) && 0 || (guess=(high+low)/2) && printf("Is it %d? (y)es, too (h)igh, too (l)ow\n", guess) && scanf("%c", &answer) && getchar() && ( (answer^'y')?( (answer^'h')?(low=guess):(high=guess) ) : printf("I win, in only %d guesses!\n", count) && 0 ) ) {}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement