Advertisement
Guest User

indovino.c

a guest
Nov 15th, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define STRLEN 256
  4. #define MAX 1000
  5. #define MIN 1
  6.  
  7. void main(void)
  8.  {char s[STRLEN];
  9.   int n,min=MIN,max=MAX+1;
  10.  
  11.   printf("Pensa un numero tra %d e %d che io provo ad indovinarlo\n",MIN,MAX);
  12.  
  13.   do
  14.    {printf("Il numero che hai pensato e' il %d (s/>/<)",n=(min+max)/2);
  15.     scanf("%s",s);
  16.     switch(s[0])
  17.      {case '>': min=n; break;
  18.       case'<': max=n; break;
  19.      }
  20.    }
  21.   while(s[0]!='s');
  22.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement