<mosaic.cnfolio.com>
PROGRAM
1. #include <stdio.h>
2. #include <stdlib.h>
3. int main(){
4.
5.   int hand1, hand2; /* Player 1 & 2, card number upto ten cards*/
6.   int number1[10]; /* Player 1, card total upto 10 values inputs each */
7.   int number2[10]; /* Player 2, card total upto 10 values inputs each */
8.   int i,j;
9.   int temp1, temp2; /* Data storage locations for bubblesort*/
10.
11.   /* Input */
12.
13.   scanf(" %d", &hand1); /* Look for input of handsize for player1*/
14.
15.   for(i = 0;i<hand1;i++){
16.       scanf(" %d", &number1[i]); /* Look for input after player 1 card values */
17.   }
18.
19.   scanf(" %d", &hand2); /* Look for input of handsize for player2*/
20.
21.   for(j = 0;j<hand2;j++){
22.       scanf(" %d", &number2[j]); /* Look for input after player 2 card values */
23.
24.   }
25.   /*Error Codes*/
26.
27.   if ((hand1< 2) || (hand1>10)){ /* If value of hand1 is above limits of 2 & 10 then display below output*/
28.
29.    printf ("Error, Player 1 you need between 2 and 10 cards!");
30.    return 0;/* Return to line 0 if above statment is true*/
31.   }
32.   if ((hand2< 2) || (hand2>10)){ /* If value of hand2 is above limits of 2 & 10 then display below output*/
33.
34.    printf ("Error, Player 2 you need between 2 and 10 cards!");
35.    return 0;/* Return to line 0 if above statment is true*/
36.   }
37.
38.
39.   /* Decending Bubble Sort*/
40.
41.      for (i = 0 ; i < ( hand1 - 1 ); i++){
42.         for (j= 0 ; j < hand1 - i - 1; j++){
43.             if(number1[j] < number1[j+1]){
44.               temp1=number1[j];
45.               number1[j]   = number1[j+1];
46.               number1[j+1] = temp1;
47.             }
48.         }
49.     }
50.
51.     for (i = 0 ; i < ( hand2 - 1 ); i++){
52.         for (j= 0 ; j < hand2 - i - 1; j++){
53.             if(number2[j] < number2[j+1]){
54.               temp2=number2[j];
55.               number2[j]   = number2[j+1];
56.               number2[j+1] = temp2;
57.             }
58.         }
59.     }
60.
61.
62.   /* Comparison */
63.
64.   for(i = 0;i<10;i++){
65.       if(hand1 == 0 && hand2 == 0 ){ /* If both hand1 & hand2 are equal to zero display below text*/
66.       printf("\nBoth players are out of cards therefore, it's a draw!");
67.       break;
68.     }
69.     if(hand1 ==0){ /* If hand1 is equal to zero display below text*/
70.       printf("\nPlayer 1 is out of cards therefore, Player 2 wins!");
71.       break;
72.     }
73.     if(hand2 ==0){ /* If hand2 is equal to zero display below text*/
74.       printf("\nPlayer 2 is out of cards therefore, Player 1 wins!");
75.       break;
76.     }
77.
78.     if(number1[i] > number2[i]){ /* If values of player1's cards > player2's then display below text*/
79.       printf("\nPlayer 1 wins!");
80.       break;
81.     }
82.     if(number2[i] > number1[i]){ /* If values of player2's cards > player1's then display below text*/
83.       printf("\nPlayer 2 wins!");
84.       break;
85.     }
86.     if(number1[i] == number2[i]){ /* If values of player1's cards are equal to player2's then display below text*/
87.       printf("\nIt's a draw!");}
88.       break;
89.     }
90.
91.