<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.  
  4. Player1, inputs Quantity of Cards   (Only allowed 2 to 10 Cards!)
  5.  
  6. IF Player1 Cards = > 10 AND < 2
  7.    THEN DISPLAY
  8.       "Player1 has too many or too less cards in hand"
  9.      ELSE CONITNUE
  10.  
  11.  
  12. Player1, inputs their cards   (Only allowed cards from 1 to 10!)
  13.  
  14. IF Player1 Cards = > 10 AND < 1
  15.    THEN DISPLAY
  16.       "Player1 has too many or too less cards in hand"
  17.       ELSE CONTINUE
  18.      
  19.  
  20. Player2, inputs Quantity of Cards   (Only allowed 2 to 10 Cards!)
  21.  
  22. IF Player2 Cards = > 10 AND < 2
  23.    THEN DISPLAY
  24.       "Player2 has too many or too less cards in hand"
  25.       ELSE CONTINUE
  26.  
  27. Player2, inputs their cards   (Only allowed cards from 1 to 10!)
  28.  
  29. IF Player2 Cards = > 10 AND < 1
  30.    THEN DISPLAY
  31.       "Player2 has too many or too less cards in hand"
  32.       ELSE CONTINUE
  33.  
  34.  
  35. Sort Player Cards from (highest to lowest)
  36.  
  37. Compare Player1 Cards Vs Player2 Cards
  38.  
  39. IF Player1 > Player2
  40. THEN DISPLAY "Player1 Wins!"
  41. ELSE
  42.    Player2 > Player1
  43.       THEN DISPLAY "Player2 Wins!"
  44. ELSE IF
  45.    Card1 = Card2
  46.       Then DISPLAY "Draw!"
  47.      
  48. END
  49. */
  50.  
  51.  
  52.  
  53.  
  54. #include <stdio.h>
  55.  
  56. int main(void)
  57. {
  58.  
  59.  
  60. int a, b, c;
  61. int Card1Total;/*Quantity of Player 1 cards  */
  62. int Card1 [10] = {0}; /* Player 1 Cards */
  63. int Card2Total = 0;/*Quantity of Player 2 cards  */
  64. int Card2 [10] = {0}; /* Player 2 Cards */
  65.  
  66.  
  67. /* Input Values) */
  68.  
  69. /* Player 1 Cards in Hand */
  70. scanf("%d", &Card1Total);
  71.     for(a = 0; a < Card1Total; a++) {
  72.         scanf("%d", &Card1[a]);
  73.     }
  74.  
  75.    /* PLayer 2 Cards in Hand */           
  76. scanf("%d", &Card2Total);
  77.     for(a = 0; a < Card2Total; a++) {
  78.         scanf("%d", &Card2[a]);
  79.     }
  80.  
  81. /* Data Validation*/
  82.  
  83.  
  84. /* Checking if Player 1 has Cards that are more than 10 and less than 2*/
  85. if(Card1Total > 10 || Card1Total < 2) {
  86.     printf("Player 1 has too many or too less cards in hand (Min is 2) (Max is 10)");
  87.     return 0;
  88.     }
  89. /* Checking if Player 2 has Cards that are more than 10 and less than 2*/
  90. if(Card2Total > 10 || Card2Total < 2) {
  91.     printf("Player 2 has too many or too less cards in hand (Min is 2) (Max is 10)");
  92.     return 0;
  93.     }
  94.  
  95. /* Checking if Player 1 has cards between 1 and 10 */
  96. for(a = 0; a < Card1Total; a++) {
  97. if(Card1[a] < 1 || Card1[a] > 10) {
  98.     printf("Player 1 has incorrect values (Min:1) (Max:10)");
  99.     return 0;
  100.     }
  101. }
  102. /* Checking if Player 2 has cards between 1 and 10 */
  103. for(a = 0; a < Card2Total; a++) {
  104. if(Card2[a] < 1 || Card2[a] > 10) {
  105.     printf("Player 2 has incorrect values (Min:1) (Max:10)");
  106.     return 0;
  107.     }
  108. }
  109. /*Sorting cards*/
  110. for(a = 0; a < Card1Total; a ++) {
  111.     for(b = 0; b < Card1Total; b++) {
  112.      if(Card1[b + 1] > Card1[b]) {
  113.          
  114.          c = Card1[b];
  115.          Card1[b] = Card1[b + 1];
  116.          Card1[b + 1] = c;
  117.          
  118.     }
  119. }
  120. }
  121. for(a = 0; a < Card2Total; a ++) {
  122.     for(b = 0; b < Card2Total; b++) {
  123.      if(Card2[b + 1] > Card2[b]) {
  124.          
  125.          c = Card2[b];
  126.          Card2[b] = Card2[b + 1];
  127.          Card2[b + 1] = c;
  128.          
  129.     }
  130. }
  131. }
  132. /*Final Result - Output*/
  133.  
  134. for(a = 0; a < 10; a++) {
  135.  
  136.  
  137.     /* Player 1: Wins!*/
  138.    
  139.    
  140.     if(Card1[a] > Card2[a]) {
  141.         printf("Player 1 Wins!");
  142.         return 0;
  143.     }
  144.  
  145.     /*Player 2: Wins!*/
  146.     if(Card2[a] > Card1[a]) {
  147.         printf("Player 2 Wins!");
  148.         return 0;
  149.     }
  150. }
  151.  
  152. /*Draw */
  153.  
  154. printf("Draw!");
  155.      }