<mosaic.cnfolio.com>
PROGRAM
1. /*
2. this game has two players
3. each player must have 2 to 10 cards at their hand
4. numbered cards thats used in this game should be 1 to 10
5. if both players are out of cards then the game ends draw
6. if player 1 has greater amount of cards than player 2 then player 1 wins
7. if player 2 has less amoount of cards than player 2 then player 2 wins
8. if one player is out of cards then the other player wins
9. */
10.
11.
12.
13. #include <stdio.h>
14.
15. void bubblesort (int array[], int n)
16. {
17.
18.         int c,d,swap;
19.      for (c = 0 ; c < (n - 1); c++)
20. {
21.          for (d = 0 ; d < n - c - 1; d++)
22. {
23.         if (array[d] < array[d+1])
24. {
25. swap = array[d];
26. array[d] = array[d+1];
27. array[d+1] = swap;
28. }
29. }
30. }
31. }
32.
33.
34.
35.       int main(void)
36. {
37.                int Gamer, o, c, d, swap;
38.
39. scanf("%d", &o);
40.        for (c = 0; c < o; c++)
41. scanf("%d", &Gamer[c]);
42. (Gamer,o);
43.
44.
45.
46.
47.      int Gamer2,m;
48. scanf("%d", &m);                 //earlier this was o, so there was error
49.     for (c = 0; c < m; c++)            // the mistake is same as above
50. scanf("%d", &Gamer2[c]);
51. (Gamer2,m);
52.
53.
54.        int judge = -1;
55.       int i=0;
56.                                 //this code is used for judgement of players, now
57.              while(i<o && i<m)
58. {
59.
60.                                 //important
61.       if(Gamer[i]>Gamer2[i])
62. {
63. judge = 0;
64. break;
65. }
66.         else if(Gamer[i]<Gamer2[i])
67. {
68. judge=1;
69.         break;
70. }
71. i++;
72.
73. }
74.     if(judge==-1 && i<o && i>=m)
75. judge = 0;
76.            else if(judge==-1 && i<m && i>=o)
77. judge = 1;
78.
79.                                    //final results
80.        if(judge==-1)
81. {
82. printf("this round finish in a Draw");
83. }
84.              else if(judge == 0)
85. {
86. printf("congratulations to Player 1 for winning this round");
87. }
88.      else if(judge == 1)
89. {
90. printf("congratulations to Player 2 for winning this round");
91. }
92.        return 0;
93. }