Advertisement
lily09290110

猜數字(輸入練習)

Jan 18th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. package cc.openhome;
  2. import java.util.Scanner;
  3. public class main {
  4.     public static void main(String[] args) {
  5.       Scanner com=new Scanner(System.in);
  6.       int num;
  7.       int number=(int)(Math.random()*10);
  8.       do{
  9.           System.out.printf("please input a number\n");
  10.           num=com.nextInt();
  11.       }while(num!=number);
  12.       System.out.printf("猜對了");
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement