One algorithm for shuffling

xiaoxiao2021-03-05  23

#include

Using namespace std;

Struct pukepai {

Char D; //

Char s; // color

}

Char Dian (INT i)

{

Switch (i)

{

Case 0: Return 'k';

Case 1: Return 'a';

Case 11: Return 'J';

Case 12: Return 'Q';

DEFAULT: RETURN I 48;

}

}

Char SPE (INT i)

{

Switch (i)

{

Case 0: return 3; // red

Case 1: Return 4; //

Case 2: return 5; //

Case 3: return 6; // black

}

}

Void Display ()

{

Pukepai P [54];

Int Temp [54], TEM, I, J

For (i = 0; i <54; i ) TEMP [i] = i 1;

SRAND (Time (0));

FOR (i = 0; i <54; i ) // Slip 1 --- 54 random number

{

TEM = rand ()% 54;

J = TEMP [I];

Temp [i] = Temp [TEM]; // If you save in an integer, you can.

Temp [TEM] = J;

}

FOR (i = 0; i <54; i ) // assignment and display

{

IF (Temp [i] == 54) p [i] .d = 's', p [i] .s = 0; // big s

ELSE IF (Temp [i] == 53) P [i] .d = 's', p [i] .s = 0; // small S

Else

{

P [I] .d = Dian (Temp [i]% 13);

P [I] .S = SPE ((Temp [i] -1) / 13);

}

}

For (i = 0; i <54; i ) cout << p [i] .s << p [i] .d << ""; // changed to this.

Cout << Endl;

}

int main ()

{

DISPLAY ();

System ("pause");

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-35620.html

New Post(0)