<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. BEGIN
  3. input number of cards in hand for player 1
  4. Start a for loop r = number of cards in hand for player 2
  5. input values of the cards in hand for player 1
  6. end for loop
  7. input number of cards in hand for player 2
  8. Start a for loop r = number of cards in hand for player 2
  9. input values of the cards in hand for player 2
  10. end for loop
  11.  
  12. IF cards in hand for players > 10
  13. PRINT error message
  14. exit programm
  15. IF cards in hand for players < 2
  16. PRINT error message
  17. exit programm
  18. IF number of cards in hand for players > 10
  19. PRINT error message
  20. exit programm
  21. IF number of cards in hand for players < 1
  22. PRINT error message
  23. exit programm
  24. IF input is character (letter)
  25. PRINT error message
  26. exit programm
  27. IF input is special character
  28. PRINT error message
  29. exit programm
  30.  
  31. BUBBLE SORT
  32. Sorting for player 1
  33. IF first card is smaller then the second one
  34. swap positions of the cards
  35. repaet until all cards are in a right order.
  36. Repeat for player 2
  37.  
  38. Scoring
  39. Compare cards of players, player with a highrer value wins
  40. IF player 1 card value < player 2 card value
  41. PRINT player 2 wins
  42. exit programm
  43.  
  44. IF player 1 card value > player 2 card value
  45. PRINT player 1 wins
  46. exit programm
  47.  
  48. IF player 1 card value = player 2 card value
  49. IF player 1 number of cards < player 2 number of cards
  50. PRINT player 2 wins
  51. exit programm
  52. IF player 1 number of cards > player 2 number of cards
  53. PRINT player 1 wins
  54. exit programm
  55. IF player 1 number of cards = player 2 number of cards
  56. PRINT DRAW
  57. exit programm
  58.  
  59. END
  60.  
  61. */
  62.  
  63. #include <stdio.h>
  64. #include <stdlib.h>
  65.  
  66. #define MAX_SIZE 10
  67.  
  68. int i, N, swap, n, d, c, B, Comp;
  69. int main()
  70. {
  71.     int Cards1[MAX_SIZE], Cards2[MAX_SIZE];
  72.    
  73.    
  74.     scanf("%d", &N);
  75.    
  76.         if(N == 0){
  77.          printf("You can only input integers\n");
  78.    return 0;
  79.    }
  80.      for(i=0; i<N; i++)
  81.     {
  82.    
  83.         scanf("%d", &Cards1[i]);
  84.          if(Cards1[i] == 0){
  85.          printf("You can only input integers\n");
  86.    return 0;
  87.    }
  88.         if(Cards1[i] > 10){
  89.          printf("highest value possible inside of the hand is 10\n");
  90.    return 0;
  91.    }
  92.    if(Cards1[i] < 1){
  93.          printf("lowest value possible inside of the hand is 1\n");
  94.    return 0;
  95.     }
  96.     }
  97.     scanf("%d", &B);
  98.      if(B == 0){
  99.          printf("You can only input integers\n");
  100.    return 0;
  101.    }
  102.      for(i=0; i<B; i++)
  103.     {
  104.         scanf("%d", &Cards2[i]);
  105.            if(Cards2[i] == 0){
  106.          printf("You can only input integers\n");
  107.    return 0;
  108.    }
  109.         if(Cards2[i] > 10){
  110.          printf("highest value possible inside of the hand is 10\n");
  111.    return 0;
  112.    }
  113.     if(Cards2[i] < 1){
  114.          printf("lowest value possible inside of the hand is 1\n");
  115.    return 0;
  116.     }
  117.     }
  118.     if(N < 2){
  119.         printf("Number of cards has to be at least 2\n");
  120.         return 0;
  121.     }
  122.    
  123.     if(B < 2){
  124.         printf("Number of cards has to be at least 2\n");
  125.         return 0;
  126.     }
  127.    
  128.     if(N > 10){
  129.          printf("Number of cards has to be at most 10\n");
  130.    return 0;
  131.     }
  132.    
  133.     if(B > 10){
  134.          printf("Number of cards has to be at most 10\n");
  135.    return 0;
  136.     }
  137.    
  138.    
  139.    
  140.    
  141.  
  142.    for (c = 0 ; c < ( N - 1 ); c++)
  143.   {
  144.     for (d = 0 ; d < N - c - 1; d++)
  145.     {
  146.       if (Cards1[d] < Cards1[d+1])
  147.       {
  148.         swap       = Cards1[d];
  149.         Cards1[d]   = Cards1[d+1];
  150.         Cards1[d+1] = swap;
  151.       }
  152.     }
  153.   }
  154.    
  155.  
  156.    for (c = 0 ; c < ( B - 1 ); c++)
  157.   {
  158.     for (d = 0 ; d < B - c - 1; d++)
  159.     {
  160.       if (Cards2[d] < Cards2[d+1])
  161.       {
  162.         swap       = Cards2[d];
  163.         Cards2[d]   = Cards2[d+1];
  164.         Cards2[d+1] = swap;
  165.       }
  166.     }
  167.   }
  168.  
  169.  if(N = B){
  170.      Comp = B;
  171.  }
  172.  
  173.  if(N < B){
  174.      Comp = B;
  175.  }
  176.  
  177.  if(N > B){
  178.      Comp = N;
  179.  }
  180.  
  181.  
  182.  for (int i = 0; i < Comp; i++)
  183.   {
  184.  
  185.    if (Cards1[i] < Cards2[i]){
  186.              printf (" Player 2 Wins ");
  187.              return 0;
  188.   }
  189.    if (Cards1[i] > Cards2[i]){
  190.            printf (" Player 1 Wins ");
  191.              return 0;
  192.   }
  193.  
  194.  
  195.  
  196.   }
  197.    if (N == B){
  198.            printf (" Draw ");
  199.   }
  200.  
  201.   if (N < B){
  202.            printf (" Player 2 Wins ");
  203.  
  204.   }
  205.   if (N > B){
  206.            printf (" Player 1 Wins ");
  207.    
  208.   }
  209.  
  210.     return 0;
  211.     }