Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define STRLEN 256
- #define MAX 1000
- #define MIN 1
- void main(void)
- {char s[STRLEN];
- int n,min=MIN,max=MAX+1;
- printf("Pensa un numero tra %d e %d che io provo ad indovinarlo\n",MIN,MAX);
- do
- {printf("Il numero che hai pensato e' il %d (s/>/<)",n=(min+max)/2);
- scanf("%s",s);
- switch(s[0])
- {case '>': min=n; break;
- case'<': max=n; break;
- }
- }
- while(s[0]!='s');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement