Import Java. util. * ;
/***/ /**
* Card Distribution Algorithm Implementation
* Requirement: Send two sub-cards, that is, 108 cards, to four people and leave 8 cards
*/
Public Class Paipai {
Int [] Pokerpai = New Int [ 54 ];
Int [] Allpai = New Int [ 108 ];
Int [] [] Playerpai = New Int [ 4 ] [ 25 ];
Int [] Dipai = New Int [ 8 ];
Int M_turn;
Random RDM = New Random (system. currenttimemillis ());
Int Getrandom ( Int Size)
{
Return(RDM. nextint ()& 0x7fffffff)%Size;
}
Public Paipai ()
{
Initpai ();
Fapai ();
}
Public Void Initpai ()
{
M_turn = 0 ;
Int Randomsite;
Int Temppai;
// Initial Value assignment-General Licensing form: 1. Issue by number of points 2. Number of cards and color
// The following is the number of points
For ( Int I = 0 ; I < Pokerpai. length; I ++ )
{
Pokerpai [I]=(I+1)%55;
}
// Give two deck cards
For ( Int I = 0 ; I < 2 ; I ++ )
For ( Int J = 0 ; J < Pokerpai. length; j ++ )
{
Allpai [m_turn]=Pokerpai [J];
M_turn++;
}
// Shuffling
For ( Int I = 0 ; I < Allpai. length; I ++ )
{< br> randomsite = getrandom (allpai. length);
temppai = allpai [randomsite];
allpai [randomsite] = allpai [I];
allpai [I] = temppai;
}
}
Public Void Fapai ()
{
// Four-person rounds, 25 rounds in total
For ( Int I = 0 ; I < 25 ; I ++ )
For ( Int J = 0 ; J < Playerpai. length; j ++ )
{
M_turn--;
Playerpai [J] [I]=Allpai [m_turn];
}
// Reserve cards
For ( Int I = 0 ; I < Dipai. length; I ++ )
{
M_turn--;
Dipai [I]=Allpai [m_turn];
}
// Show four cards
For ( Int J = 0 ; J < Playerpai. length; j ++ )
Showpai (playerpai [J]);
// Display Base card
Showpai (dipai );
}
Public Void Showpai ( Int [] M_pai)
{
System. Out. println ( " Showpai: Start. " );
For ( Int I = 0 ; I < M_pai.length; I ++ )
{
System. Out. Print (" "+M_pai [I]);
}
System. Out. println ();
System. Out. println ( " Showpai: end. " );
}
Public Static Void Main (string [] ARGs)
{
NewPaipai ();
}
}