Home > Software engineering >  For this problem how to do it tomorrow to test!!!!!! With VB.NET!!!!! Red envelopes for you!!!
For this problem how to do it tomorrow to test!!!!!! With VB.NET!!!!! Red envelopes for you!!!

Time:09-25

3. Please design a hand than the size of the game, players have five Numbers 1, 2, 3, 4, 5 respectively hand, players must each sequence is not repeated in a card with a computer than size (of course, computers and only 1, 2, 3, 4, 5, a total of five CARDS, not repeat play), please let the player can use design (drop-down menu) to select the Numbers on the hand, and please play all hand shows the outcome after five rounds, (15%)
Example:

Players computer
2 5
1
43 2
4 1
5 3

CodePudding user response:

Shuffle algorithm, refer to the following:
 # include & lt; Stdio. H> 
#include
#include
Int d [6];
Int I, n, a, b, t;
C, int j;
Void main () {
Srand (time (NULL));
Printf (" shuffle 0.. N - 1 demo \ n ");
For (n=1; n<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
J=1;
For (c=1; C<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; C<=j; C + +) {/* test n * 2 * n! Time */
for (i=0; iFor (I=n; i> 0; I -) {/* disturb 0 ~ */n - 1
A=I - 1; B=rand () % I;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
for (i=0; iprintf("\n");
}
}
Printf (" shuffle 1.. N demo \ n ");
For (n=1; n<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
J=1;
For (c=1; C<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; C<=j; C + +) {/* test n * 2 * n! Time */
For (I=1; i<=n; I++) d [I]=I;/* fill in 1 ~ n */
For (I=n; i> 1; I -) {/* disturb 1 ~ n */
A=I; B=rand () % I + 1;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
For (I=1; i<=n; I++) printf (" % d ", d [I]);
printf("\n");
}
}
}
  • Related