package com.lu;
import java.util.Random;
import java.util.Scanner;
public class Text6 {//抢红包
public static void main(String[] args) {
double[] arr = {9,9999,6,8,88};
grabTheRedEnvelope(arr);
}
public static void grabTheRedEnvelope(double[] arr){
Scanner input = new Scanner(System.in);
Random r = new Random();
for (int i = 0; i < arr.length; i++) {
System.out.println("请输入任何符号抽奖");
input.next();
int a = r.nextInt(5);
while (true){
if (arr[a]==0){
a = r.nextInt(5);
continue;
}
break;
}
System.out.println("恭喜你抽中红包"+arr[a]+"元!");
arr[a]=0;
}
}
}
java抢红包控制台小游戏
最新推荐文章于 2024-11-11 00:03:55 发布