有用的话请给一小小的赞 ,谢谢各位大佬了
package 寒假;
import java. util .*;
public class caishuzi {
public static void main(String[] args) {
Random o= new Random();
int c=o.nextInt(100);
for(int j=1;;){
Scanner r = new Scanner(System.in);
System.out.println("请输入你要猜的数字");
int x=r.nextInt();
System.out.println("这是你猜的第"+j+"次");
j++;
if(x>c) {
System.out.println("你猜的数字大了,在猜一遍试试");
}else if(c>x) {
System.out.println("你猜的数小了,在猜一遍试试");
} else if(c==x) {
System.out.println("恭喜你猜对了");
return;
}
}
}
}



