<mosaic.cnfolio.com>
PROGRAM
1. /*Pseudocode
2.
3. acquire Player 1 quantity
4.
5. if player 1 quantity is less than two
6. then display error message
7. end if
8.
9. if player 1 quantity is greater than ten
10. then display error message
11. end if
12.
13. acquire Player 1 cards
14.
15. if player 1 cards is less than one
16. then display error message
17. end if
18.
19. if player 1 cards is greater than ten
20. then display error message
21. end if
22.
23.
24. repeat if statements for player 1 cards for every value within the card list
25.
26. sort player 1 cards from highest to lowest
27.
28.
29. acquire Player 2 quantity
30.
31. if player 2 quantity is less than two
32. then display error message
33. end if
34.
35. if player 2 quantity is greater than ten
36. then display error message
37. end if
38.
39.
40. acquire Player 2 cards
41.
42. if player 2 cards is less than one
43. then display error message
44. end if
45.
46. if player 2 cards is greater than ten
47. then display error message
48. end if
49.
50.
51. repeat if statements for player 2 cards for every value within the card list
52.
53. sort player 2 cards from highest to lowest
54.
55.
56. game outcome conditons
57.
58.
59. compare all of player 1 cards with player 2 cards if identical
60. then display "It's a draw!"
61.
62. compare all of player 1 cards with player 2 cards if player 1 cards is greater than player 2 cards
63. then display "Congratulations! Player 1 wins!"
64.
65. compare all of player 1 cards with player 2 cards if player 2 cards is greater than player 1 cards
66. then display "Congratulations! Player 2 wins!"
67.
68.
69. repeat game outcome conditions ten times*/
70.
71.
72.
73.
74. #include <stdio.h>
75.
76. int main(){
77.
78.     int j, i, a, b, player1quantity = 0, player1cards[10], player2quantity = 0, player2cards[10], store;
79.
80.     scanf ("%d", &player1quantity);
81.
82.     {
83.
84.     if (player1quantity < 2){
85.         printf ("Error: Player1 needs more than two cards.");
86.
87.     return 0;
88.
89.     }
90.
91.     if (player1quantity > 10){
92.         printf ("Error: Player1 needs less than ten cards.");
93.
94.     return 0;
95.
96.     }
97.
98.
99.     for (j = 0; j < player1quantity; j++){
100.
101.     scanf("%d", &player1cards[j])
102.
103.     }
104.
105.
106.     for (j = 0; j < player1quantity -1; j++){
107.
108.     for (i = 0; i < player1quantity -1; i++){
109.
110.     if  (player1cards[i + 1] > player1cards[i]){
111.
112.         store = player1cards[i];
113.         player1cards[i] = player1cards[i + 1];
114.         player1cards[i + 1] = store;
115.
116.     }
117.   }
118. }
119.
120. }
121.
122.       for (i = 0; i < player1quantity; i++){
123.         printf("%d ", player1cards[i]);
124.
125.
126.     }
127.
128.       scanf ("%d ", &player2quantity );
129.
130.     {
131.
132.     if (player2quantity < 2){
133.         printf (" Error: Player2 needs more than two cards.");
134.
135.     return 0;
136.
137.     }
138.
139.     if (player2quantity > 10){
140.         printf (" Error: Player2 needs less than ten cards.");
141.
142.     return 0;
143.
144.     }
145.
146.
147.     for (a = 0; a < player2quantity; a++){
148.     scanf("%d", &player2cards[a]);
149.
150.     }
151.
152.
153.     for (a = 0; a < player2quantity -1; a++){
154.
155.     for (b = 0; b < player2quantity -1; b++){
156.
157.     if  (player2cards[b + 1] > player2cards[b]){
158.
159.         store = player2cards[b];
160.         player2cards[b] = player2cards[b + 1];
161.         player2cards[b + 1] = store;
162.
163.     }
164.   }
165. }
166.
167. }
168.
169.     for (b = 0; b < player2quantity; b++){
170.        printf("%d ", player2cards[b]);
171.
172.
173.     }
174.
175.     for (j = 0; j < 10; j++){
176.
177.     if (player1quantity == player2quantity);
178.         printf ("It's a draw!");
179.         return 0;
180.
181.     if (player1quantity > player2quantity);
182.         printf ("Congratulations! Player 1 wins!");
183.         return 0;
184.
185.     if (player2quantity > player1quantity);
186.         printf ("Congratulations! Player 2 wins!");
187.         return 0;
188.  }
189.
190.
191. return 0;
192.
193. }