您的位置:首页 > 其它

模拟猜数(POJ2328)

2016-05-12 20:54 190 查看
题目链接:http://poj.org/problem?id=2328

解题报告:

缩短区间,soeasy,

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <limits.h>

using namespace std;

int main()
{
int n,begin = 0,end = INT_MAX;
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: