public static void main(String[] args) {
int num = (int)(Math.random()*100)+1;
int count = 0;
System.out.println("请输入您猜的数字1到100之间:");
Scanner sc = new Scanner(System.in);
while(true){
int x = sc.nextInt();
count++;
if(x<num){
System.out.println("猜的数小了");
}else if(x>num){
System.out.println("猜的数大了");
}else if(x == num){
System.out.println("恭喜你猜对了,大神");
System.out.println("总共猜了"+count+"次");
break;
}