public class LottoNumber {
public static void main(String[] args) {
//一副牌,用一副52张的牌,随机选择四张,牌用0到51表示
int[] deck = new int[52];
int i;
for(i=0;i<=51;i++)
deck[i] = i;//建立一个数组,进行赋值
String[] suits = {"Spades","Hearts","Diamonds","Clubs"};//花色
String[] ranks = {"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"};//牌的大小
for(i=0;i<deck.length;i++)//应用随机数,使得牌相互交换,进行洗牌
{
int random = (int)(Math.random()*deck.length);//deck.length是52,产生之间的随机数进行交换
int t = deck[i];
deck[i] = deck[random];
deck[random] = t;
}
for(i=0;i<4;i++)
{
int color = deck[i]/13;//得到花色
String color1 = suits[color];
int number = deck[i]%13;//得到具体花色的哪张牌
String number1 = ranks[number];
System.out.println("Card is "+color1+" of "+number1);
}
}
}