<mosaic.cnfolio.com>
PROGRAM
1. #include <stdio.h>
2.
3.    /*Pseudo Code
4.
5.    START
6.
7.       obtain playerA input
8.       obtain playerB input
9.       sort playerA & playerB input's into ascending order
10.
11.       WHILE Both playerA and playerB have inputed values
12.
13.          compear playerA & playerB first inputs
14.             IF playerA's first input is larger than playerB's first input
15.                playerA Wins
16.             ELCE
17.                PlayerB Wins
18.             ELCE IF  playerA's first input is equal to playerB's First input
19.                check next value in both playerA's and playerB's inputs
20.             IF no more inputs
21.                draw
22.
23.      END WHILE
24.
25.    END
26.
27.    */
28.
29.  int main ( void )
30.
31.  {
32.
33. /*veriables*/
34.
35.    int x;
36.    int y;
37.    int temporary_value1;
38.    int temporary_value2;
39.    int playerA_card_quantity = 0;   /* the number of cards in playerA's hand */
40.    int playerB_card_quantity = 0;   /* the number of cards in playerB's hand */
41.    int playerA_hand[10] = {0};   /* Array that stores the cards in playerA's hand */
42.    int playerB_hand[10] = {0};   /* Array that stores the cards in playerB's hand */
43.
44. /* inputs */
45.
46.    scanf("%d", &playerA_card_quantity);
47.    for(x = 0; x < playerA_card_quantity; x++)
48.    {
49.       scanf("%d", &playerA_hand[x]);
50.    }
51.
52.    scanf("%d", &playerB_card_quantity);
53.    for(x = 0; x < playerB_card_quantity; x++)
54.    {
55.       scanf("%d", &playerB_hand[x]);
56.    }
57.
58. /* error checking */
59.
60.   if (playerA_card_quantity < 2 || playerA_card_quantity > 10)
61.         {
62.          printf ( "This is an invalid card quantity\nthe number of cards in each player's hand must be at least 2 and no greater than ten" );
63.          return;
64.         }
65.
66.   if (playerB_card_quantity < 2 || playerB_card_quantity > 10)
67.         {
68.          printf ( "This is an invalid card quantity\nthe number of cards in each player's hand must be at least 2 and no greater than 10" );
69.          return;
70.         }
71.
72.     /*for (playerA_card_quantity)
73.     {
74.      (if (playerA_hand < 1 || playerA_hand > 10)
75.       {
76.        printf ( "One or more of the card numbers is impossible\nAll card numbers must be 1 or more, and 10 or less" );
77.     return;
78.       }
79.     }
80.
81.   for (playerB_card_quantity)
82.     {
83.      (if (playerB_hand < 1 || playerB_hand > 10)
84.       {
85.        printf ("One or more of the card numbers is imposable\nAll card numbers must be 1 or more, and 10 or less");
86.     return;
87.       }
88.     }*/
89.
90.    /*This section of the error checking is suposed to ensuser that all of the numbers entered in each players had is a posable numbered card that is alowed in the game rules. However it causes this folowing error
91.      : In function 'main':
92.     Line 7331: ERROR: expected ';' before ')' token
93.      for (playerA_card_quantity)
94.                                ^
95.      compilation terminated due to -Wfatal-errors.
96.      I was unable to resolve this error*/
97.
98. /* sorting */
99.
100.    for (x = 0; (x <= playerA_card_quantity); x++)
101.     {
102.    for (y = 0; (y <= playerA_card_quantity - 1); y++)
103.       {
104.         if (playerA_hand[y + 1] > playerA_hand[y])
105.          {
106.           temporary_value2 = playerA_hand[y];
107.           playerA_hand[y] = playerA_hand[y + 1];
108.           playerA_hand[y + 1] = temporary_value2;
109.          }
110.       }
111.     }
112.
113.    for (x = 0; (x <= playerB_card_quantity); x++)
114.     {
115.    for (y = 0; (y <= playerB_card_quantity - 1); y++)
116.       {
117.          if (playerB_hand[y + 1] > playerB_hand[y])
118.           {
119.            temporary_value2 = playerB_hand[y];
120.            playerB_hand[y] = playerB_hand[y + 1];
121.            playerB_hand[y + 1] = temporary_value2;
122.           }
123.       }
124.     }
125.
126. /* outcome calculation */
127.
128.    for (x = 0; x < 10; x++)
129.     {
130.       if (playerA_hand[x] > playerB_hand[x])
131.         {
132.           printf ( "Game results in Player A Wining!" );
133.         return;
134.         }
135.
136.       if (playerB_hand[x] > playerA_hand[x])
137.         {
138.             printf ( "Game results in Player B Winning!" );
139.         return;
140.         }
141.     }
142.     printf( " game results in a draw");
143.     return;
144.
145.  }