猜数字案例
package com.demo.test; import java.util.Random; import java.util.Scanner; public class rr { public static void main(String[] args) { r(); } public static void r() { Scanner sc = new Scanner(System.in); Random r = new Random(); int num = r.nextInt(100); while (true){ int num2 = sc.nextInt(); if (num > num2){ System.out.println("您猜小了"); }else if (num < num2){ System.out.println("您猜大了"); }else { System.out.println("您猜对了"); break; } } } }
标签:java,num2,System,Random18,num,println,out From: https://www.cnblogs.com/wencaiguagua/p/17172697.html