Poker
1. Define an array that holds 1-52 (52 cards, no big, Little King)
Of these, 1 means that the a,2 of spades means that the 2...,13 of spades means the spades K, and 14 means the Red peach ...)
2. Randomly arrange the array
3. Then average the cards to 4 players (divided into 4 arrays, according to the rules of the licensing)
4. Sort the output of each player's poker (according to the suit: spades, Hearts, clubs, squares; then size)
<! DOCTYPE html>varArr=[]; //1. Store 1-52 cards in arr array for(vari=1;i<=52;i++) {Arr[arr.length]=i; } //2. ShuffleArr.sort (function(){ returnMath.random ()-0.5; }); //3. Define the player array varplayers=[]; for(vari=0;i<4;i++) {Players[i]=[]; } //4. Licensing for(vari=0;i<52;i++){ //0,4,8 //1,5,9Players[i%4].push (Arr[i]); } //5. Player Sort for(vari=0;i<4;i++) {Players[i].sort (function(A, b) {returnA-b; }); } //Console.log (arr); //Console.log (players); //6. Output varTypes=["Spades", "Hearts", "Plum", "squares"]; varnums=["A", "2", "3", "4", "5", "6", "7", "8", "9", "Ten", "J", "Q", "K"]; for(vari=0;i<4;i++) {Console.log (' Player ' + (i+1) + "card:"); for(varj=0;j<13;j++){ varn=Players[i][j]; varType=math.floor ((n-1)/13)//n-1 corresponding subscript 0123varsno= (n-1)%13;//n-1 corresponding subscript 0-13Console.log (types[type]+Nums[sno]); } console.log (' ========== '); } </script>April 6--an exercise on the number of algorithms--Poker Shuffle