java 猜数字
package java05; import java.util.Random; import java.util.Scanner; public class DemoGuessnum { public static void main(String[] args) { Random r = new Random(); int randomnum = r.nextInt(100)+1; Scanner s = new Scanner(System.in); while (true){ int mynum = s.nextInt(); if (mynum>randomnum){ System.out.println("大了"); }else if(mynum <randomnum){ System.out.println("小了"); }else{ System.out.println("猜对了"); break; } } } }