java,课堂练习,
import java.util.Scanner; public class a { public static void main(String[] args) { for(int j=1;;j++){ Scanner sc=new Scanner(System.in); System.out.println("请输入年龄:"); int i=sc.nextInt(); int a=23; if(i<0||i>110) { System.out.println("输入错误!请重新输入!"); }else if(i>a) { System.out.println("猜大了"); }else if(i<a) { System.out.println("猜小了"); }else { System.out.println("猜对了"); break; } } } }