---------双色球
import java.util.Random;
import java.util.Scanner;
public class quanCaiPaoJiangHai {
public static void main(String[] arge){
Scanner scan = new Scanner(System.in);
int[] ints = new int[7];
int i=1;
int g;
boolean pd = false;
while(i<=7){ //用输入做控制
if(i==7){
System.out.print("输入蓝色球号码:");
g = scan.nextInt();
if(g>0&&g<=16){
ints[i-1]=g;
}else{continue;}
}else{
System.out.print("输入想要中奖的"+i+"号码:");
g = scan.nextInt();
if(g>0&&g<=33){
ints[i-1]=g;
}else{continue;}}
for(int j=0;j<i-1;j++){
if(ints[j]==ints[i-1]){pd = true;break;}
}
if(!pd){
i++;
}else {pd = false;}
}
String s=create(ints);
System.out.print(s);
}
public static String create(int[] ints){
int[] redPoll = new int[]{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};
int[] bluePoll = new int[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
int[] six = new int[6];
int[] one = new int[1];
int k;
int zj=0;
String str="";
//取中奖号码
for(k=0;k<6;k++){
Random rand = new Random();
int ch = rand.nextInt(33-k);
six[k]=redPoll[ch]; //移位操作
redPoll[ch]=redPoll[32-k];
}
for(k = 0;k<6;k++){
for(int i=0;i<6;i++){
if(six[k]<six[i])
{int s=six[i];
six[i]=six[k];
six[k]=s;
}
}
}
Random rand = new Random();
int ch = rand.nextInt(16);
one[0] = bluePoll[ch];
//中奖号码比较
for(int i=0;i<6;i++){
for(int j=0;j<6;j++){
if(ints[i]==six[j])
zj++;
}
}
//判断是否中奖
switch(zj){
case 6:if(ints[6]==one[0])
System.out.println("恭喜你中了一等奖!!");
else
System.out.println("恭喜你中了二等奖!!");
break;
case 5:if(ints[6]==one[0])
System.out.println("恭喜你中了三等奖!!");
else
System.out.println("恭喜你中了四等奖!!");
break;
case 4: if(ints[6]==one[0])
System.out.println("恭喜你中了四等奖!!");
else
System.out.println("恭喜你中了五等奖!!");
break;
case 3: if(ints[6]==one[0])
System.out.println("恭喜你中了五等奖!!");
else System.out.println("很抱歉你没有中奖!!!");
break;
case 2: if(ints[6]==one[0])
System.out.println("恭喜你中了六等奖!!");
else System.out.println("很抱歉你没有中奖!!!");
break;
case 1: if(ints[6]==one[0])
System.out.println("恭喜你中了六等奖!!");
else System.out.println("很抱歉你没有中奖!!!");
break;
case 0: if(ints[6]==one[0])
System.out.println("恭喜你中了六等奖!!");
else System.out.println("很抱歉你没有中奖!!!");
break;
}
//中奖号码的排序和输出;
System.out.print("中奖号码:");
for(int i=0;i<6;i++){
if(six[i]<10){
str=str+"0"+six[i]+"\t";
}else {
str = str+six[i]+"\t";
}
}
String str1="";
if(one[0]<10)
str1= str+"\n"+"蓝色球:"+"0"+one[0];
else str1= str+"\n"+"蓝色球:"+one[0];
return str1;
}
}