POJ 2328 大水题

来源:互联网 发布:算法导论中文第三版pdf 编辑:程序博客网 时间:2024/04/27 06:50

求个最大值最小值,right on的时候判断一下是否合法就可以了。

 

#include <iostream>
#include <string.h>
using namespace std;
char buff[30];
int main(){
    int n,max,min,x;
    while (1){
        min=-1;
        max=100;
        while (1){
            cin>>x;
            cin.get();
            if (x==0) return 0;
            buff[0]='\0';
            cin.getline(buff,25);
            if (strcmp(buff,"too high")==0) {
                if (max>x) max=x;
            }
            else if (strcmp(buff,"too low")==0){
                if (min<x) min=x;
            }
            else {
     //           cout<<"max="<<max <<","<< "min="<<min<<endl;
                if (min<x&&x<max) cout<<"Stan may be honest\n";
                else cout<<"Stan is dishonest\n";
                break;
            }
        }
    }

    return 0;
}

原创粉丝点击