<mosaic.cnfolio.com>
PROGRAM
1. /*START*/
2. /* Get how many cards to sort
3.    Get all cards to sort
4.    Set the position number to zero
5.    WHILE the position number is one less than the quantity of cards to sort
6.       Look in all positions higher than the current position to find the highest card
7.       Swap the highest card and the card at the current position
8.       Increase the position number by one
9.    END WHILE
10.
11. IF the first player's highest card is higher than the second player's highest card
12.   THEN
13.       Display Player 1 wins
14.    ELSE
15.       IF The second player's highest card is higher than the first player's highest card
16.     THEN
17.       Display Player 2 wins
18.     ELSE
19.       IF The first player's highest card is equal to to the second player's highest c
20.      THEN
21.         Display Draw
22. END IF*/
23.
24.  /* Get highest value card from player1
25. Remove highest value card from array from player1
26. Get highest value card from player2
27. Remove highest value card from array from player2
28.
29. IF the first player's highest card is higher than the second player's highest card
30.   THEN
31.       Display Player 1 wins
32.    ELSE
33.       IF The second player's highest card is higher than the first player's highest card
34.     THEN
35.       Display Player 2 wins
36.     ELSE
37.       IF The first player's highest card is equal to to the second player's highest c
38.      THEN
39.         Display Draw
40. END IF*/
41.
42. /*Continue until out of cards
43.
44.
45. /*END*/
46.
47. #include <stdio.h>
48.
49. int main( void )
50.
51. {
52.
53.  int array[10], nOfCards, c, d, swap, maximum, location = 1;
54.
55.
56.   scanf("%d", &nOfCards);
57.
58.   nOfCards<=10;
59.  if (nOfCards  > 10)
60.  printf ("number of cards must be less than 10\n");
61.   for (c = 0; c < nOfCards; c++)
62.     scanf("%d", &array[c]);
63.
64.   for (c = 0 ; c < ( nOfCards - 1 ); c++)
65.   {
66.     for (d =0 ; d < nOfCards - c - 1; d++)
67.     {
68.       if (array[d] < array[d+1])
69.       {
70.         swap       = array[d];
71.         array[d]   = array[d+1];
72.         array[d+1] = swap;
73.       }
74.     }
75.   }
76.
77.
78.
79.
80.
81.
82.
83.  int array2[10], nOfCards2, a, b, swap2, maximum2, location2 = 1;
84.
85.
86.   scanf("%d", &nOfCards2);
87.
88.   nOfCards2 < 11;
89.
90.    if (nOfCards2  > 10)
91.  printf ("number of cards must be less than 10\n");
92.
93.   for (a = 0; a < nOfCards2; a++)
94.     scanf("%d", &array2[a]);
95.
96.   for (a = 0 ; a < ( nOfCards2 - 1 ); a++)
97.   {
98.     for (b = 0 ; b < nOfCards2 - a - 1; b++)
99.     {
100.       if (array2[b] < array2[b+1])
101.       {
102.         swap2       = array2[b];
103.         array2[b]   = array2[b+1];
104.         array2[b+1] = swap2;
105.       }
106.     }
107.   }
108.
109.   for ( c = 0 ; c < nOfCards ; c++ )
110.        maximum = array[0];
111.
112.   for (c = 1; c < nOfCards; c++)
113.   {
114.     if (array[c] > maximum)
115.     {
116.        maximum  = array[c];
117.        location = c+1;
118. }
119. }
120.
121.
122.
123.   for ( a = 0 ; a < nOfCards2 ; a++ )
124.       maximum2 = array2[0];
125.
126.   for (a = 1; a < nOfCards2; a++)
127.   {
128.     if (array2[a] > maximum2)
129.     {
130.        maximum2  = array2[a];
131.        location2 = a+1;
132. }
133. }
134.
135.
136.
137.    if (maximum2 > maximum)
138.
139.    printf("Player 2 wins\n");
140.
141.     if (maximum > maximum2)
142.
143.    printf ("Player 1 wins!\n");
144.
145.
146.    if(maximum == maximum2)
147.
148.
149.    printf (" Draw\n");
150.
151.    }