标签:void mat ati img length ++ src 算法 wicket
核心步骤:利用随机数给数组赋值。
1 public class wicket_2 { 2 public static void main(String[] args) { 3 String []s=new String[]{"黑桃","红桃","梅花","方块"}; 4 String []sign=new String[]{"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; 5 final int N=52; 6 int card[]=new int[N]; 7 for(int i=0;i<card.length;i++) { 8 card[i]+=i; 9 } 10 System.out.println("开始时牌顺序:"); 11 for(int i=0;i<card.length;i++) { 12 System.out.printf(" %s%s",s[card[i]/13],sign[card[i]%13]); 13 if((i+1)%13==0) { 14 System.out.println(); 15 } 16 } 17 //模拟洗牌 18 for(int i=0;i<card.length;i++) { 19 card[i]=(int)((Math.random())*52); 20 } 21 System.out.println("洗牌后的顺序为:"); 22 for(int i=0;i<card.length;i++) { 23 System.out.printf(" %s%s",s[card[i]/13],sign[card[i]%13]); 24 if((i+1)%13==0) { 25 System.out.println(); 26 } 27 } 28 } 29 }
运算结果:
标签:void mat ati img length ++ src 算法 wicket
原文地址:https://www.cnblogs.com/mianyang0902/p/10805233.html