java猜数字

java猜数字,第1张

import java. util. Scanner;

import java. util. Random;

public class caishuzi{

public static void main("String[] args"){

             Random r = new random();

             Scanner sc = new Scanner(System.in);

              int x = r. nextInt(100) + 1;

              while(true){

                       int y = sc. nextInt;

                       if(x >y) {
                                
                           System. out. println("你猜的数字比实际偏小");

                        }
                        else if(x < y){
                            System. out. println("你猜的数比实际偏大");
                        }else{
                            System. out. println("恭喜你,猜对了!");
                        }

              }

    }

}

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/792761.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-05
下一篇2022-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存