<mosaic.cnfolio.com>
PROGRAM
1. /*START
2.
3. Do WHILE
4.
5.        Player 1 draws cards within the range 2 to 10
6.   IF
7.       Card amount is out of range
8.   THEN
9.       Display error message card amount out of range
10.
11.   END IF
12.
13.       Player 2 draws cards within the range 2 to 10
14.   IF
15.       Card amount is out of range
16.   THEN
17.       Display error message card amount out of range
18.
19.   END IF
20.
21.     player 1 sorts cards from highest to lowest in desending order 10 to 1
22.   IF
23.       Card numer is out of range
24.   THEN
25.       Display error message card number out of range
26.
27.   END IF
28.
29.      player 2 sorts cards from highest to lowest in desending order 10 to 1
30.   IF
31.       Card numer is out of range
32.   THEN
33.       Display error message card number out of range
34.
35.   END IF
36.
37.   END Do WHILE
38.
39.        Calculate sum of cards in player 1 hand
40.        Calculate sum of cards in player 2 hand
41.   IF
42.        Player 1 takes turn showing their highest card
43.   THEN
44.
45.      Player 2 takes turn showing thier highest card
46.
47.   END IF
48.
49.   IF
50.      Player 1 has the highest sum of cards
51.
52. THEN
53.
54.     Display Player 1 winner messsage
55.
56. END IF
57.
58.   IF
59.        Player 2 has the highest sum cards
60.   THEN
61.        Display player 2 winner message
62.
63.   END IF
64.
65.   IF
66.        Player 1 and Player 2 draw identical card value
67.   THEN
68.        Display draw message
69.
70.   END IF
71.
72.        Resume game and start next round
73.
74.   IF
75.        player 1 and player 2 are both out of cards
76.
77.   Then
78.        Display draw message
79.   END IF
80.
81. */
82.
83.  #include <stdio.h>
84.  #include <stdlib.h>
85.
86.
87.   int main(void)
88. {
89.   int hand_size_one;
90.   int hand_size_two;
91.   int PlayerOneInput={0};                                        // 10 slots in this array
92.   int PlayerTwoInput={0};                                       // 10 slots in this array
93.
94.   scanf( "%d", &hand_size_one );                                    //player 1 begins
95.   printf("Player Ones Handsize = %d\n",hand_size_one);
96.
97.   int count = 0 ;
98.
99.   if ( hand_size_one <2 || hand_size_one >10 )
100.   {
101.   printf ( " error - handsize out of range \n " );                  //out of error message
102.   }
103.   int player1_cards;
104.   int  i=0;
105.   for ( int i=0; i < hand_size_one ; i++ )
106.   { scanf("%d " , &PlayerOneInput[i]);}
107.   for ( int i=0; i < hand_size_one;i++)
108.
109.
110.   for (int i = 0; i < hand_size_one; i++ )
111.  {
112.   if ( PlayerOneInput [i] < 1 )
113.   {printf ("error- card number is less than 0 \n");
114.   return 0;
115.   } else if ( PlayerOneInput[i] > 10 ){
116.   printf ( " error - card number is more than 10  \n " );
117.  return 0;}
118.  }
119.
120.                                                                     // Bubsort player 1
121.   int temp;
122.   for (int j= 0; j <hand_size_one-1 ; j++)
123.   {
124.   for (int i= 0; i <hand_size_one-1 ; i++)
125.   {
126.   if ( PlayerOneInput[i] < PlayerOneInput[i+1])
127.   {
128.   temp = PlayerOneInput[i];
129.   PlayerOneInput[i] = PlayerOneInput[i+1];
130.   PlayerOneInput[i+1] = temp;
131.   }
132.   }
133.   }
134.                                                                     //  player one hand size numbers
135.   printf("Player Ones cards  \n");
136.   for ( int i=0 ; i < hand_size_one ; i++)
137.   {
138.   printf ("%d " , PlayerOneInput[i]);
139.   }
140.
141.   scanf( "%d", &hand_size_two );                                    //player 2 begins
142.   printf("\nPlayer Twos Handsize = %d",hand_size_two);
143.   int _count = 0 ;
144.  if ( hand_size_two <2 || hand_size_two >10 )
145.   {
146.   printf ( " error - handsize out of range \n " );                  // out of range error message
147.   }
148.   printf ( "\n" );
149.
150.   for ( int i=0; i < hand_size_two ; i++ )
151.   {
152.   scanf("%d" , &PlayerTwoInput[i]);
153.   }
154.
155.   if ( PlayerTwoInput [i] < 2 ){
156.   printf( "error- card number is less than 0 \n");
157.   return (0);
158.    }
159.    else if ( PlayerTwoInput[i] >10) {
160.   printf ( "error- card number is more than 10 \n");
161.   }
162.
163.
164.
165.
166.                                                                   // Bubsort player 2
167.   int temp_;
168.   for (int j= 0; j <hand_size_two -1 ; j++)
169.   {
170.   for (int i= 0; i <hand_size_two -1 ; i++)
171.   {
172.   if ( PlayerTwoInput[i] < PlayerTwoInput[i+1])
173.   {
174.   temp_ = PlayerTwoInput[i];
175.   PlayerTwoInput[i] = PlayerTwoInput[i+1];
176.   PlayerTwoInput[i+1] = temp_;
177.   }
178.   }
179.   }
180.                                                                    // Player two hand size numbers
181.   printf ("Player twos cards\n");
182.   for ( int i=0 ; i < hand_size_two ; i++)
183.   {
184.   printf("%d " , PlayerTwoInput[i]);
185.   }
186.   printf("\n");
187.
188.                                                                        // possible outcomes
189.  { for(i=0; i<PlayerOneInput; i++){
190.   if ( PlayerOneInput[i] < PlayerTwoInput[i])
191.   {
192.   printf ("Player 2 wins \n");
193.   return 0 ;
194.   }else if ( PlayerOneInput[i] > PlayerTwoInput[i]){
195.   printf ("Player 1 wins \n")
196.   return 0;
197.   }else if ( PlayerOneInput[i] == PlayerTwoInput[i]){
198.   printf( "Round ends in draw \n");
199.   }
200.   }
201.   }
202.   }