本帖最後由 葉桔良 於 2022-7-9 14:59 編輯
- import java.util.*;
- public class JPD02 {
- public static void main(String[] args) {
- test();
- test();
- test();
- test();
- test();
- }
-
- static void test() {
- double rand=0;
- rand = Math.random()*10+1;
- System.out.println((int)(rand));
- }
- }
複製代碼- package test;
- public class YAYA {
- public static void main(String[] args) {
- test2();
-
- test();
- }
-
- static void test() {
- double rand=0;
- rand = Math.random()*10+1;
- if((int)(rand)==10)
- System.out.print((int)(rand));
- else{
- System.out.print("0");
- System.out.print((int)(rand));
- }
- }
- static void test2() {
- double rand=0;
- rand = Math.random()*3+1;
- System.out.print((int)(rand));
- }
- }
複製代碼 |