終極密碼遊戲:

終極密碼流程圖.GIF

 

 import java.util.*;
public class Game {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = (int)(Math.random()*99)+1;
        while(true){
            System.out.println("請輸入 1 ~ 99");
            int y = scanner.nextInt();
            if(x == y){
                System.out.println("對不起害到你");
                break;
            }else if(x > y){
                System.out.println("大一點");
            }else{
                System.out.println("小一點");
            }
        }
    }
}

創作者介紹
創作者 pandaalbert(冠文)的部落格 的頭像
pandaalbert冠文

pandaalbert(冠文)的部落格

pandaalbert冠文 發表在 痞客邦 留言(0) 人氣( 549 )