就一个游戏,猜数字,你说一个数字,可能大了或者小了,最后再猜一次~控制下区间,如果在区间里那可能就是诚实的,不在的话肯定说谎了~水题,输入有点小问题。 #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string.h> #include <limits.h> using namespace std; int main(void) { int n,begin = 0,end = INT_MAX; int x; char str[10]; while( cin >> n && n ) { getchar(); begin = 0,end = INT_MAX; while ( gets(str) && strcmp(str,"right on") ) { if( strcmp(str,"too high") == 0 && n < end ) end = n; else if( strcmp(str,"too low") == 0 && n > begin ) begin = n; cin >> n; getchar(); } if( n > begin && n < end ) printf("Stan may be honest/n"); else printf("Stan is dishonest/n"); } return 0; }