package com.huxiao.object;
import java.util.Scanner;
public class GussNum {
/**
* 猜数字小游戏
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*Scanner sc=new Scanner(System.in);
System.out.println("请输入您猜的数纸");
int guessnum=sc.nextInt();*/
int random=(int) (Math.random()*100+1);
while(true){
Scanner sc=new Scanner(System.in);
System.out.println("请输入您猜的数纸");
int guessnum=sc.nextInt();
if(guessnum>random){
System.out.println("大了");
}else if(guessnum<random){
System.out.println("小了");
}else {
System.out.println("恭喜你猜中了");
break;
}
}
}
}
|
|