`
200830740306
  • 浏览: 106396 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

poj2328

阅读更多
package easy;


import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 *
 *poj2328
 * 刚开始没有想清楚,猜数时,可能出现一些痴的情况
 * @author NC
 */
public class Poj2328 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        while (scan.hasNext()) {
            int n = 0;
            int low = 0;
            int high = 11;
            while (true) {
                n = Integer.parseInt(scan.nextLine().trim());
                if (n == 0) {
                    System.exit(0);
                }
                String s = scan.nextLine().trim();
                if (s.equals("too high")) {
                    if (n < high) {
                        high = n;
                    }
                }
                if (s.equals("too low")) {
                    if (n > low) {
                        low = n;
                    }
                }
                if (s.equals("right on")) {
                    break;
                }
            }
            if (n > low && n < high) {
                System.out.println("Stan may be honest");
            } else {
                System.out.println("Stan is dishonest");
            }
        }
    }
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics