首页 > 其他 > 详细

模拟猜数(POJ2328)

时间:2016-05-13 12:24:47      阅读:151      评论:0      收藏:0      [点我收藏+]

题目链接: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;
}

 

模拟猜数(POJ2328)

原文:http://www.cnblogs.com/TreeDream/p/5487292.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!