1-100猜数字
public class Cz {
//编写一个猜数字的游戏1-100
public static void main(String[] args) {
//设置随机数
int a = (int) (Math.random() * 100+1);
int g;
System.out.println("欢迎猜数字!");
do {
System.out.println("请输入一个1-100的数字");
Scanner sc = new Scanner(System.in);
g = sc.nextInt();
if (g > a){
System.out.println("大了");
}else if (g < a){
System.out.println("小了");
}
}while (g!=a);
System.out.println("中了");
}
}