package ch6;
import java.io.*;
public class ch6_26_2
{
public static void main(String awgs[])throws IOException
{
int ha,hg=0;
int cg=0,cb=0,cc=100,ct=0,cont=0;
String sha,shg;
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
System.out.println("type a number between 1~100");
sha=buf.readLine();
ha=Integer.parseInt(sha);
do
{
cont++;
cg=(int)(Math.random()*(cc-cb)+cb);
ct=cg;
System.out.println("is "+ct+"?1 for biger,2 for yes,3 for to smaller");
shg=buf.readLine();
hg=Integer.parseInt(shg);
if(hg==1)
cc=cg;
if(hg==3)
cb=cg;
}while(hg!=2);
System.out.println(ct+" is answer,for "+cont+" times");
}
}
============================
type a number between 1~100
50
is 63?1 for biger,2 for yes,3 for to smaller
1
is 18?1 for biger,2 for yes,3 for to smaller
3
is 49?1 for biger,2 for yes,3 for to smaller
3
is 56?1 for biger,2 for yes,3 for to smaller
1
is 52?1 for biger,2 for yes,3 for to smaller
1
is 50?1 for biger,2 for yes,3 for to smaller
2
50 is answer,for 6 times
留言列表