
Prog challenge#1 - diff
By:
snarez on
Feb 10th, 2012 | syntax:
C | size: 0.44 KB | hits: 309 | expires: Never
#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;
}