import java.util.Random;
public class Niu
{
public static void main(String[] args)
{
int[] arry=new int[5];
int i,j,k;
int sum=0,niu=0,l=0;
int x=0;
Random random = new Random();
System.out.println("----------斗牛小游戏----------");
System.out.println("-------电脑随机产生五张牌------");
for(i=0;i<5;i++)
{
l=random.nextInt(12)+1;
if(l==1)
System.out.print(" "+"A");
else if(l==11)
System.out.print(" "+"J");
else if (l==12)
{
System.out.print(" "+"Q");
}
else if (l==13)
{
System.out.print(" "+"K");
}
else System.out.print(" "+l);
arry[i]=(l>10?10:l);
sum+=arry[i];
niu=sum%10;
}
System.out.println();
for(i=0;i<4;i++)
{
k=10-(arry[i]+arry[i+1])%10;
for(j=0;j<5;j++)
{
if(j!=i&&j!=(i+1))
{
if(arry[j]==k)
{
x=1;
break;
}
}
}
}
if(x==1)
{
if(niu==0)
System.out.println("恭喜你!此盘牌为牛满");
else System.out.println("恭喜你!此盘牌为牛"+niu);
}
else System.out.println("对不起!此盘牌为没牛!");
}
} |
|