随机数选择器 Exercise07_13

 1 import java.util.Scanner;
 2 /**
 3  * @author 冰樱梦
 4  *时间:2018年下半年
 5  *题目:随机数选择器
 6  */
 7 public class Exercise07_13 {
 8     public static void main(String[] args){
 9         int[] list={1,23,89,23,4};
10         System.out.println(getRadom(list));
11     }
12     
13     //返回1到54之间的随机数
14     public static int getRadom(int... numbers){
15         int random=(int) (1+Math.random()*54);
16         for(int i=0;i<numbers.length;i++){
17             if(random==numbers[i]){
18                 random=(int) (1+Math.random()*54);
19             }
20         }
21         return random;
22     }
23 }

猜你喜欢

转载自www.cnblogs.com/cherrydream/p/10174099.html