public class Test1{
public static void main(String[] args){
int[] sysRedBall = new int[6];//存储系统生成的红球
int sysBlueBall = 0;//存储系统生成的的蓝球
int[] userRedBall = new int[6];//存储用户选择的红球
int userBlueBall = 0;//存储用户选择的蓝球
int redCount = 0;//正确的红球个数
int blueCount = 0;//正确的蓝球个数
Random r = new Random();
int[] redBall = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33};
//游戏开始
System.out.println("双色球游戏开始,祝你好运!");
int index = 0;
//生成系统号码
for(int i=0;i<sysRedBall.length;i++){
while(true){
index = r.nextInt(33);
if(redBall[index]!=-1){
sysRedBall[i] = redBall[index];
redBall[index] = -1;
break;
}
}
}
sysBlueBall = r.nextInt(16)+1;
//接收用户选号
System.out.println("请选择红球号码(1-33)");
Scanner in = new Scanner(System.in);
for(int i=0;i<userRedBall.length;i++){
userRedBall[i] = in.nextInt();
}
System.out.println("请选择蓝球号码(1-16)");
userBlueBall = in.nextInt();