第2个回答 2014-12-14
以下运行就可以了
public class test {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
Random r=new Random();
int computer=r.nextInt(100);
int times=1;
System.out.println(computer);
System.out.println("系统已产生一个随机数字(0~99),请问是多少?");
while(true){
int you=Integer.parseInt(s.next());
if(you>computer){
System.out.println("你猜的数字太大了!再猜!");
times++;
}else if(you<computer){
System.out.println("你猜的数字太小了!再猜!");
times++;
}else {
if(times==1){
System.out.println("你太厉害了,一次就猜对。");
}else if(times>1 && times<7){
System.out.println("你很聪明!");
}else{
System.out.println("你笨死了,猜这么多次!");
}
break;
}
}
}
}