Pages

Sunday 9 September 2012

UVA - 10530 - Guessing Game

import java.io.*;
import java.util.IllegalFormatException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

public class Main{

    public static void main(String[] args) throws FileNotFoundException {
        TextIO.readStream(System.in);
        int max=11;
        int min=0;
        while(true){
            int x=TextIO.getlnInt();
            if(x==0)
                break;
            String temp=TextIO.getlnString();
            if("too high".equals(temp)){
                if(x<max)
                    max=x;
            }
            else if("too low".equals(temp)){
                if(x>min)
                    min=x;
            }
            else{
              if(x>min && x<max)
                  System.out.println("Stan may be honest");
              else
                  System.out.println("Stan is dishonest");
              max=11;
              min=0;
            } 
        }
}
}

No comments:

Post a Comment