<mosaic.cnfolio.com>
PROGRAM
1. /*
2. START
3.
4. Set all cards to zero
5.
6. Read how many cards player one is using
7.
8. Read cards player one is using
9.
10. Read number of cards player two is using
11.
12. Read cards player two is using
13.
14. Check player one's cards are less than ten but not zero
15.
16. Check player two's cards are less than ten but not zero
17.
18. Check player one's cards are in desending order
19.
20. Check player two's cards are in desending order
21.
22. Player with highest card wins
23.
24. END
25. */
26. #include<stdio.h>
27. int main(void)
28. {
29.    /*Initaizing the number of cards each player will be using*/
30.    int p1_num, p2_num;
31.
32.    /*Initalizing each players cards*/
33.    int p1_cards [10] = {0}
34.    int p1_1 = 0, p1_2 = 0, p1_3 = 0, p1_4 = 0, p1_5 = 0, p1_6 = 0, p1_7 = 0, p1_8 = 0, p1_9 = 0, p1_10 = 0;
35.    int p2_cards [10] = {0}
36.    int p2_1 = 0, p2_2 = 0, p2_3 = 0, p2_4 = 0, p2_5 = 0, p2_6 = 0, p2_7 = 0, p2_8 = 0, p2_9 = 0, p2_10 = 0;
37.
38.    /*Scanning number of cards player 1 will be using*/
39.    scanf("%d",&p1_num);
40.
41.    /*Scanning player 1's cards depending on the number of cards player 1 is using*/
42.    if(p1_num == 2)
43.     {scanf("%d %d", &p1_1, &p1_2);}
44.    else if(p1_num == 3)
45.     {scanf("%d %d %d", &p1_1, &p1_2, &p1_3);}
46.    else if(p1_num == 4)
47.     {scanf("%d %d %d %d", &p1_1, &p1_2, &p1_3, &p1_4);}
48.    else if(p1_num == 5)
49.     {scanf("%d %d %d %d %d", &p1_1, &p1_2, &p1_3, &p1_4, &p1_5);}
50.    else if(p1_num == 6)
51.     {scanf("%d %d %d %d %d %d", &p1_1, &p1_2, &p1_3, &p1_4, &p1_5, &p1_6);}
52.    else if(p1_num == 7)
53.     {scanf("%d %d %d %d %d %d %d", &p1_1, &p1_2, &p1_3, &p1_4, &p1_5, &p1_6, &p1_7);}
54.    else if(p1_num == 8)
55.     {scanf("%d %d %d %d %d %d %d %d", &p1_1, &p1_2, &p1_3, &p1_4, &p1_5, &p1_6, &p1_7, &p1_8);}
56.    else if(p1_num == 9)
57.     {scanf("%d %d %d %d %d %d %d %d %d", &p1_1, &p1_2, &p1_3, &p1_4, &p1_5, &p1_6, &p1_7, &p1_8, &p1_9);}
58.    else if(p1_num == 10)
59.     {scanf("%d %d %d %d %d %d %d %d %d %d", &p1_1, &p1_2, &p1_3, &p1_4, &p1_5, &p1_6, &p1_7, &p1_8, &p1_9, &p1_10);}
60.
61.    /*If player 1 isn't using between two or ten cards*/
62.    else
63.     {printf("Player 1 needs between two and ten or cards");}
64.
65.    /*Scanning number of cards player 2 will be using*/
66.    scanf("%d", &p2_num);
67.
68.    /*Scanning player 2's cards depending on the number of cards player 2 is using*/
69.    if(p2_num == 2)
70.     {scanf("%d %d", &p2_1, &p2_2);}
71.    else if(p2_num == 3)
72.     {scanf("%d %d %d", &p2_1, &p2_2, &p2_3);}
73.    else if(p2_num == 4)
74.     {scanf("%d %d %d %d", &p2_1, &p2_2, &p2_3, &p2_4);}
75.    else if(p2_num == 5)
76.     {scanf("%d %d %d %d %d", &p2_1, &p2_2, &p2_3, &p2_4, &p2_5);}
77.    else if(p2_num == 6)
78.     {scanf("%d %d %d %d %d %d", &p2_1, &p2_2, &p2_3, &p2_4, &p2_5, &p2_6);}
79.    else if(p2_num == 7)
80.     {scanf("%d %d %d %d %d %d %d", &p2_1, &p2_2, &p2_3, &p2_4, &p2_5, &p2_6, &p2_7);}
81.    else if(p2_num == 8)
82.     {scanf("%d %d %d %d %d %d %d %d", &p2_1, &p2_2, &p2_3, &p2_4, &p2_5, &p2_6, &p2_7, &p2_8);}
83.    else if(p2_num == 9)
84.     {scanf("%d %d %d %d %d %d %d %d %d", &p2_1, &p2_2, &p2_3, &p2_4, &p2_5, &p2_6, &p2_7, &p2_8, &p2_9);}
85.    else if(p2_num == 10)
86.     {scanf("%d %d %d %d %d %d %d %d %d %d", &p2_1, &p2_2, &p2_3, &p2_4, &p2_5, &p2_6, &p2_7, &p2_8, &p2_9, &p2_10);}
87.
88.    /*If player 2 isn't using between two or ten cards*/
89.    else
90.     {printf("Player 2 needs between two and ten or cards");}
91.
92.    /*Ensuring each of Player 1's cards are all less than 10*/
93.    if((p1_1 > 10)||(p1_1 == 0))
94.     {printf("Player 1's first card is invalid");}
95.    if((p1_2 > 10)||(p1_2 == 0))
96.     {printf("Player 1's second card is invalid");}
97.    if((p1_3 > 10)||(p1_3 == 0)&&(p1_num > 2))
98.     {printf("Player 1's third card is invalid");}
99.    if((p1_4 > 10)||(p1_4 == 0)&&(p1_num > 3))
100.     {printf("Player 1's forth card is invalid");}
101.    if((p1_5 > 10)||(p1_5 == 0)&&(p1_num > 4))
102.     {printf("Player 1's fith card is invalid");}
103.    if((p1_6 > 10)||(p1_6 == 0)&&(p1_num > 5))
104.     {printf("Player 1's sixth card is invalid");}
105.    if((p1_7 > 10)||(p1_7 == 0)&&(p1_num > 6))
106.     {printf("Player 1's seventh card is invalid");}
107.    if((p1_8 > 10)||(p1_8 == 0)&&(p1_num > 7))
108.     {printf("Player 1's eighth card is invalid");}
109.    if((p1_9 > 10)||(p1_9 == 0)&&(p1_num > 8))
110.     {printf("Player 1's ninth card is invalid");}
111.    if((p1_10 > 10)||(p1_10 == 0)&&(p1_num > 9))
112.     {printf("Player 1's tenth card is invalid");}
113.
114.    /*Ensuring each of Player 2's cards are all less than 10*/
115.    if((p2_1 > 10)||(p2_1 == 0))
116.     {printf("Player 2's first card is invalid");}
117.    if((p2_2 > 10)||(p2_2 == 0))
118.     {printf("Player 2's second card is invalid");}
119.    if((p2_3 > 10)||(p2_3 == 0)&&(p2_num > 2))
120.     {printf("Player 2's third card is invalid");}
121.    if((p2_4 > 10)||(p2_4 == 0)&&(p2_num > 3))
122.     {printf("Player 2's forth card is invalid");}
123.    if((p2_5 > 10)||(p2_5 == 0)&&(p2_num > 4))
124.     {printf("Player 2's fith card is invalid");}
125.    if((p2_6 > 10)||(p2_6 == 0)&&(p2_num > 5))
126.     {printf("Player 2's sixth card is invalid");}
127.    if((p2_7 > 10)||(p2_7 == 0)&&(p2_num > 6))
128.     {printf("Player 2's seventh card is invalid");}
129.    if((p2_8 > 10)||(p2_8 == 0)&&(p2_num > 7))
130.     {printf("Player 2's eighth card is invalid");}
131.    if((p2_9 > 10)||(p2_9 == 0)&&(p2_num > 8))
132.     {printf("Player 2's ninth card is invalid");}
133.    if((p2_10 > 10)||(p2_10 == 0)&&(p2_num > 9))
134.     {printf("Player 2's tenth card is invalid");}
135.
136.    /*Ensuring Player 1 has stated their cards in desending order*/
137.    else if((p1_1 < p1_2)&&(p1_num == 2))
138.       {printf("Player 1's cards must be in desendeing order");}
139.    else if((p1_1 < p1_2)||(p1_2 < p1_3)&&(p1_num == 3))
140.       {printf("Player 1's cards must be in desendeing order");}
141.    else if((p1_1 < p1_2)||(p1_2 < p1_3)||(p1_3 < p1_4)&&(p1_num == 4))
142.       {printf("Player 1's cards must be in desendeing order");}
143.    else if((p1_1 < p1_2)||(p1_2 < p1_3)||(p1_3 < p1_4)||(p1_4 < p1_5)&&(p1_num == 5))
144.       {printf("Player 1's cards must be in desendeing order");}
145.    else if((p1_1 < p1_2)||(p1_2 < p1_3)||(p1_3 < p1_4)||(p1_4 < p1_5)||(p1_5 < p1_6)&&(p1_num == 6))
146.       {printf("Player 1's cards must be in desendeing order");}
147.    else if((p1_1 < p1_2)||(p1_2 < p1_3)||(p1_3 < p1_4)||(p1_4 < p1_5)||(p1_5 < p1_6)||(p1_6 < p1_7)&&(p1_num == 7))
148.       {printf("Player 1's cards must be in desendeing order");}
149.    else if((p1_1 < p1_2)||(p1_2 < p1_3)||(p1_3 < p1_4)||(p1_4 < p1_5)||(p1_5 < p1_6)||(p1_6 < p1_7)||(p1_7 < p1_8)&&(p1_num == 8))
150.       {printf("Player 1's cards must be in desendeing order");}
151.    else if((p1_1 < p1_2)||(p1_2 < p1_3)||(p1_3 < p1_4)||(p1_4 < p1_5)||(p1_5 < p1_6)||(p1_6 < p1_7)||(p1_7 < p1_8)||(p1_8 < p1_9)&&(p1_num == 9))
152.       {printf("Player 1's cards must be in desendeing order");}
153.    else if((p1_1 < p1_2)||(p1_2 < p1_3)||(p1_3 < p1_4)||(p1_4 < p1_5)||(p1_5 < p1_6)||(p1_6 < p1_7)||(p1_7 < p1_8)||(p1_8 < p1_9)||(p1_9 < p1_10)&&(p1_num == 10))
154.       {printf("Player 1's cards must be in desendeing order");}
155.
156.    /*Ensuring Player 2 has stated their cards in desending order*/
157.    else if((p2_1 < p2_2)&&(p2_num == 2))
158.       {printf("Player 2's cards must be in desendeing order");}
159.    else if((p2_1 < p2_2)||(p2_2 < p2_3)&&(p2_num == 3))
160.       {printf("Player 2's cards must be in desendeing order");}
161.    else if((p2_1 < p2_2)||(p2_2 < p2_3)||(p2_3 < p2_4)&&(p2_num == 4))
162.       {printf("Player 2's cards must be in desendeing order");}
163.    else if((p2_1 < p2_2)||(p2_2 < p2_3)||(p2_3 < p2_4)||(p2_4 < p2_5)&&(p2_num == 5))
164.       {printf("Player 2's cards must be in desendeing order");}
165.    else if((p2_1 < p2_2)||(p2_2 < p2_3)||(p2_3 < p2_4)||(p2_4 < p2_5)||(p2_5 < p2_6)&&(p2_num == 6))
166.       {printf("Player 2's cards must be in desendeing order");}
167.    else if((p2_1 < p2_2)||(p2_2 < p2_3)||(p2_3 < p2_4)||(p2_4 < p2_5)||(p2_5 < p2_6)||(p2_6 < p2_7)&&(p2_num == 7))
168.       {printf("Player 2's cards must be in desendeing order");}
169.    else if((p2_1 < p2_2)||(p2_2 < p2_3)||(p2_3 < p2_4)||(p2_4 < p2_5)||(p2_5 < p2_6)||(p2_6 < p2_7)||(p2_7 < p2_8)&&(p2_num == 8))
170.       {printf("Player 2's cards must be in desendeing order");}
171.    else if((p2_1 < p2_2)||(p2_2 < p2_3)||(p2_3 < p2_4)||(p2_4 < p2_5)||(p2_5 < p2_6)||(p2_6 < p2_7)||(p2_7 < p2_8)||(p2_8 < p2_9)&&(p2_num == 9))
172.       {printf("Player 2's cards must be in desendeing order");}
173.    else if((p2_1 < p2_2)||(p2_2 < p2_3)||(p2_3 < p2_4)||(p2_4 < p2_5)||(p2_5 < p2_6)||(p2_6 < p2_7)||(p2_7 < p2_8)||(p2_8 < p2_9)||(p2_9 < p2_10)&&(p2_num == 10))
174.       {printf("Player 2's cards must be in desendeing order");}
175.
176.    /*Observing which player's first card has a larger value*/
177.    else if(p1_1 > p2_1)
178.     {printf("Player 1 Wins!");}
179.    else if(p1_1 < p2_1)
180.     {printf("Player 2 Wins!");}
181.
182.    /*If both players' cards are the same the players' next cards are compaired*/
183.    else if(p1_2 > p2_2)
184.     {printf("Player 1 Wins!");}
185.    else if(p1_2 < p2_2)
186.     {printf("Player 2 Wins!");}
187.
188.    /*If both player's first 2 cards are the same*/
189.    else if(p1_3 > p2_3)
190.     {printf("Player 1 Wins!");}
191.    else if(p1_3 < p2_3)
192.     {printf("Player 2 Wins!");}
193.
194.    /*If both player's first 3 cards are the same*/
195.    else if(p1_4 > p2_4)
196.     {printf("Player 1 Wins!");}
197.    else if(p1_4 < p2_4)
198.     {printf("Player 2 Wins!");}
199.
200.    /*If both player's first 4 cards are the same*/
201.    else if(p1_5 > p2_5)
202.     {printf("Player 1 Wins!");}
203.    else if(p1_5 < p2_5)
204.     {printf("Player 2 Wins!");}
205.
206.    /*If both player's first 5 cards are the same*/
207.    else if(p1_6 > p2_6)
208.     {printf("Player 1 Wins!");}
209.    else if(p1_6 < p2_6)
210.     {printf("Player 2 Wins!");}
211.
212.    /*If both player's first 6 cards are the same*/
213.    else if(p1_7 > p2_7)
214.     {printf("Player 1 Wins!");}
215.    else if(p1_7 < p2_7)
216.     {printf("Player 2 Wins!");}
217.
218.    /*If both player's first 7 cards are the same*/
219.    else if(p1_8 > p2_8)
220.     {printf("Player 1 Wins!");}
221.    else if(p1_8 < p2_8)
222.     {printf("Player 2 Wins!");}
223.
224.    /*If both player's first 8 cards are the same*/
225.    else if(p1_9 > p2_9)
226.     {printf("Player 1 Wins!");}
227.    else if(p1_9 < p2_9)
228.     {printf("Player 2 Wins!");}
229.
230.    /*If both player's first 9 cards are the same*/
231.    else if(p1_10 > p2_10)
232.     {printf("Player 1 Wins!");}
233.    else if(p1_10 < p2_10)
234.     {printf("Player 2 Wins!");}
235.
236.    /*If all of both players cards are the same*/
237.    else
238.     {printf("Draw");}
239.
240. printf("'%d %d %d %d %d %d %d %d %d %d'", p1_1, p1_2, p1_3, p1_4, p1_5, p1_6, p1_7, p1_8, p1_9, p1_10);
241. }