<mosaic.cnfolio.com>
PROGRAM
1. Begin
2. Player 1 draws 3 cards
3. THEN player 1 lists the cards they have in their hand
4. Player 2 draws 3 cards
5. THEN player 2 lists the cards they have in their hand
6. The cards get organized in the hand from highest card to the lowest
7. Both players show their highest rated card
8. IF one player has a higher card then the other player then the game ends and the player with the higher card wins
9. •   PRINT which player won
10. ELSE
11. •   Don’t print
12. ENDIF
13. IF both players have the same card number then they show the next highest card
14. •   Repeat until one player has a higher card than the other
15. ELSE
16. •   Player with the remaining card or cards wins
17. ENDIF
18. But if both players run out of cards at the same round then they draw
19. End
20.
21. #include <stdio.h>
22. #include <stdlib.h>
23. #include <time.h>
24.
25. void shuffle( int wDeck[][ 10 ] );
26. void deal( const int wDeck[][ 10 ] );
27.
28. int main( void )
29. {
30.
31.    int deck [ 10 ];
32.
33.    srand( time( 0 ) );
34.
35.    shuffle ( deck );
36.    deal ( deck );
37. }
38.
39. void shuffle( int wDeck[] [ 10 ] )
40. {
41.    int row;
42.    int column;
43.    int card;
44.
45.    for ( card = 1; card <= 10; card++ ) {
46.
47.    do {
48.       row = rand() % 1;
49.       column = rand () % 10;
50.       } while ( wDeck[ row ] [ column ] );
51.
52.       wDeck [ row ] [ column ] = card;
53.    }
54. }
55.
56. void deal ( const int wDeck[] [ 10 ] )
57. {
58.    int card;
59.    int row;
60.    int column;
61.
62.    for ( card = 1; card <= 3; card++ ) {
63.
64.       for ( row = 0; row <= 3; row++ ) {
65.
66.          for ( column = 0; column <= 9; column++ ) {
67.
68.             if ( wDeck [ row ][ column ] == card ) {
69.
70.                printf( "%s"),
71.                card %1 == 1 ? '/n' :
72.             }
73.          }
74.       }
75.    }
76. }
77.
78. int shuffle( int wDeck[][ 10 ] )
79. {
80.    return deck ()%/n;
81. }