Card Wash algorithm

Source: Internet
Author: User
Tags shuffle

Import java.util.random;class card{int suit;//suit char number;//number}public class Pokeshow {static card[] Onecard=new    CARD[52];   Save each poker suit, digital static void Showcard ()//show Poker {int i, J;   int sign=0;   String s= "";  for (i = 0, j = 0; i < K; i++, J + +) {if (J 13==0) {System.out.print ("\ n"); } switch (Onecard[i].  Suit)//display suit symbol {case 1:s= "spades";  sign=3;  Break  Case 2:s= "Red peach";  sign=4;  Break  Case 3:s= "Plum";  sign=5;  Break  Case 4:s= "Block";  sign=6;  Break  Default:; } System.out.printf ("" +s+onecard[i]. number);//Output display} System.out.print ("\ n");}    static void Shuffle ()//algorithm {int i,j,temp;int suit;   Card tempcard=new card (); suit=0;  for (i = 0; i < i++)//Generate 52 cards {if (i = = 0) {suit++;//change suit} card t=new card ();  T.suit = suit;//Save Color temp = i% 13;  Switch (temp)//Special value processing {case 0:t.number = ' A ';  Break  Case 9:t.number = ' 0 ';  Break  Case 10:t.number = ' J ';  Break  Case 11:t.number = ' Q ';  Break Case 12:t.number = 'K ';  Break  Default:t.number = (char) (temp + ' 1 ');   } onecard[i]=t;    } System.out.printf ("The initial arrangement of a new card is as follows: \ n");   Showcard ();  Random r=new random ();//stochastic seed for (i = 0; i < K; i++) {j = R.nextint (52);//random card change Tempcard = Onecard[j];  ONECARD[J] = Onecard[i];   Onecard[i] = Tempcard; }}public static void Main (string[] args) {Shuffle ();//Shuffle System.out.print ("\ n Shuffle the following arrangement: \ n"); Showcard ();//Display the new card's Arrangement}}

Card Wash algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.