SHARE
TWEET

Prog challenge#1 - diff

snarez Feb 10th, 2012 677 Never
  1. #include <stdio.h>
  2. int main(){
  3.   int high=100, low=1, guess=0, count=0;
  4.   char answer;
  5.  
  6. 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 ) ) {}
  7.  
  8.   return 0;
  9. }
RAW Paste Data
Top