package ssq; import java.util.Arrays; import java.util.Random; import java.util.Scanner; public class text { public static void main(String[] args) { int[] redball = new int[6]; int blueball = 0; Random ran = new Random(); for (int i = 0; i < redball.length - 1; i++) { int index = ran.nextInt(33) + 1; redball[i] = index; for (int j = 0; j < i; j++) { if (redball[i] == redball[j]) { i--; } } } redball[5] = ran.nextInt(16) + 1; Arrays.sort(redball, 0, 6); String str = Arrays.toString(redball); Random go = new Random(); int index1 = go.nextInt(16) + 1; blueball = index1; System.out.println("开奖号码为:" + str + blueball); System.out.println("输入六位红色号码:"); int[] userBall = new int[6]; Scanner red = new Scanner(System.in); for (int i = 0; i < redball.length; i++) { userBall[i] = red.nextInt(); } System.out.println("输入一位蓝色号码"); int userBall1 = 0; Scanner blue = new Scanner(System.in); userBall1 = blue.nextInt(); int rednumber = 0; int bluenumber = 0; for (int i = 0; i < redball.length; i++) { for (int j = 0; j < userBall.length; j++) { if (redball[i] == userBall[j]) { rednumber++; } } } if (userBall1 == blueball) { bluenumber++; } if (rednumber == 6 && bluenumber == 1) { System.out.println("恭喜你,中一等奖500万"); } else if (rednumber == 6 && bluenumber == 0) { System.out.println("恭喜你,中二等奖100万"); } else if (rednumber == 5 && bluenumber == 1 || rednumber == 5 && bluenumber == 0) { System.out.println("恭喜你,中三等奖3000元"); } else if (rednumber == 4 && bluenumber == 1 || rednumber == 4 && bluenumber == 0) { System.out.println("恭喜你,中四等奖200元"); } else if (rednumber < 4 && bluenumber == 1) { System.out.println("恭喜你,中五等奖5元"); } else { System.out.println("感想你为公益事业做出贡献"); } } }
09-13
1467
04-06