import java.util.Scanner; //导包 class LianXi { public static void main(String[] args) { System.out.println("输入数字"); Scanner sc = new Scanner(System.in); //创建键盘输入对象
int number = (int)(Math.random()*100)+1;//获得一到一百的随机数 int a = 1; //定义一个变量 while (a <= 8) { int x = sc.nextInt(); if ( number < x ) { System.out.println("大了"); }else if ( number > x) { System.out.println("小了"); }else if (x == number) { System.out.println("猜对了"); } a++; continue;