<mosaic.cnfolio.com>
PROGRAM
  1. /* PSEUDO CODE
  2.   START
  3.     Read first number and make it equal to num1
  4.    
  5.     IF num1 is equal or less than 10
  6.    
  7.      IF num1 is more or equal to 2
  8.      
  9.         DO loop num1 amounts of times
  10.          Read the next number and make it part of a range of numbers called player1
  11.          
  12.           DO loop num1 amounts of times
  13.            DO loop num1 minus 1 amounts of times
  14.              IF first card smaller than second card
  15.               Move first card to the right
  16.              END If
  17.     Read next number and make it equal to num2
  18.    
  19.     IF num2 is equal or less than 10
  20.    
  21.      IF num2 is more or equal to 2
  22.      
  23.        DO loop num2 amounts of times
  24.           Read the next number and make it part of a range of numbers called player2
  25.          
  26.          DO loop num2 amounts of times
  27.           DO loop num2 minus 1 amounts of times
  28.             IF first card smaller than second card
  29.              Move first card to the right   
  30.             END IF
  31.          
  32.     IF set of numbers from the array of cards in player1 is smaller than the number 10   
  33.      
  34.       IF set of numbers from the array of cards in player2 is smaller than the number 10   
  35.            
  36.        IF num1 is more than or equal to num2
  37.         Do loop num1 amounts of times
  38.      
  39.          IF player1 bigger than player 2 (note : player 1 and player 2 can be a range of 10 numbers or less, it must compare first set of cards and second sets together and so on progressively)
  40.            Show player 1 wins and STOP program
  41.  
  42.            ELSE  IF player2 bigger than player 1 (note : player 1 and player 2 can be a range of 10 numbers or less, it must compare first set of cards and second sets together and so on progressively)
  43.             Show player2 wins and STOP program
  44.      
  45.              ELSE IF player 1 and player 2 are equal
  46.                add one to a variable called draws
  47.              IF draws is equal to num1
  48.                Show it’s a draw and STOP program
  49.              END IF
  50.  
  51.      
  52.         IF num1 is less to num2
  53.              Do loop num2 amounts of times
  54.              
  55.              IF player1 bigger than player 2 (note : player 1 and player 2 can be a range of 10 numbers or less, it must compare first set of cards and second sets together and so on progressively)
  56.               Show player 1 wins and STOP program
  57.  
  58.            ELSE  IF player2 bigger than player 1 (note : player 1 and player 2 can be a range of 10 numbers or less, it must compare first set of cards and second sets together and so on progressively)
  59.             Show player2 wins and STOP program
  60.      
  61.              ELSE IF player 1 and player 2 are equal
  62.                add one to a variable called draws
  63.                IF draws is equal to num1
  64.                  Show it’s a draw and STOP program
  65.                END IF
  66.              
  67.     ELSE show player 2 has a card thats higher than 10
  68.    
  69.    ELSE show player 1  has a card thats higher than 10
  70.  
  71.   ELSE show number of cards is too small 
  72.  
  73.   ELSE show number of cards is too big
  74.   ]
  75.   ELSE show number of cards is too small
  76.  
  77.   ELSE show number of cards is too big
  78.  
  79.  
  80. END
  81. */
  82.  
  83.  
  84.  
  85. #include <stdio.h>
  86. void main()
  87. {
  88.     int player1[10], player2[10];
  89.     int i, j, num1, temp, num2, winner, maxnum;
  90.    
  91.    /*first player scanning of numbers and arrenging numbers in order */
  92.     scanf("%d", &num1);
  93.     printf("Player 1 has %d cards.\n", num1);
  94.   if (num1 <= 10) /* limiting amount of cards to 10 */
  95.   {
  96.    if (num1 >= 2) /*setting min amount of cards to 2*/
  97.   {
  98.      for (i = 0; i < num1; i++) /* loop num1 amount of times*/
  99.      {
  100.         scanf("%d", &player1[i]);/* reads player 1 cards*/
  101.      }
  102.  
  103.      /*   Bubble sorting begins */
  104.      for (i = 0; i < num1; i++)
  105.      {
  106.          for (j = 0; j < (num1 - 1); j++)
  107.          {
  108.              if (player1[j] < player1 [j + 1])
  109.              {
  110.                  temp = player1[j];            /* takes p1 first card compares it to the second if its lower moves it to the right*/
  111.                  player1[j] = player1[j + 1];
  112.                  player1[j + 1] = temp;
  113.              }
  114.          }
  115.       }
  116.      printf("Sorted array is... ");
  117.      for (i = 0; i < num1; i++)
  118.      {
  119.         printf("%d ", player1[i]);
  120.      }
  121.    
  122.     /*second player scanning of numbers and arrenging numbers in order  same process as player one*/
  123.     scanf("%d", &num2);
  124.     printf("\nPlayer 2 has %d cards.\n", num2);
  125.   if (num2 <= 10) /* limiting amount of cards to 10 */
  126.   {
  127.    if (num2 >= 2)
  128.    {
  129.      for (i = 0; i < num2; i++)
  130.      {
  131.         scanf("%d", &player2[i]);
  132.      }
  133.  
  134.      /*   Bubble sorting begins */
  135.      for (i = 0; i < num2; i++)
  136.      {
  137.          for (j = 0; j < (num2 - 1); j++)
  138.          {
  139.              if (player2[j] < player2 [j + 1])
  140.              {
  141.                  temp = player2[j];
  142.                  player2[j] = player2[j + 1];
  143.                  player2[j + 1] = temp;
  144.              }
  145.          }
  146.       }
  147.      printf("Sorted array is... ");
  148.      for (i = 0; i < num2; i++)
  149.      {
  150.         printf("%d ", player2[i]);
  151.      }   
  152.   /* comparing values of the cards begins*/ 
  153.   winner = 0 ;
  154.   maxnum = 10;
  155.  
  156.   if (player1[0] <= maxnum)
  157.   {
  158.   if (player2[0] <= maxnum)
  159.   {
  160.   if (num1 >= num2)
  161.   {
  162.     for (i = 0; i < num1 ; i++)
  163.          {
  164.          
  165.             if(player1[i] > player2[i])
  166.             {
  167.                printf("\nPlayer 1 wins");
  168.                break;
  169.             }
  170.                else if (player1[i] < player2[i])
  171.                  {
  172.                    printf("\nPlayer 2 wins");
  173.                   break;
  174.                   }
  175.                     else if (player1[i] = player2[i], winner++)  /* if there is a dra it adds one to the variable winner*/
  176.                     {
  177.                     if (winner == num1)  /* if there is as many draws as there is the max amount of cards its a dran game*/
  178.                     {
  179.                        printf("\nIts a draw");
  180.                        break;
  181.                     }                                     
  182.                     }
  183.                    
  184.    }
  185.    }
  186.    else if (num1 < num2)
  187.   {
  188.     for (i = 0; i < num2 ; i++)
  189.          {
  190.          
  191.             if(player1[i] > player2[i])
  192.             {
  193.                printf("\nPlayer 1 wins");
  194.                break;
  195.             }
  196.                else if (player1[i] < player2[i])
  197.                  {
  198.                    printf("\nPlayer 2 wins");
  199.                   break;
  200.                   }
  201.                     else if (player1[i] = player2[i], winner++) /* if there is a dra it adds one to the variable winner*/
  202.                     {
  203.                        if (winner == num2)  /* if there is as many draws as there is the max amount of cards its a dran game*/
  204.                        {
  205.                        printf("\nIts a draw");
  206.                        break;
  207.                        }
  208.                      } 
  209.  }
  210.  
  211.  }
  212.   }
  213.  else printf("\nplayer 2 has a card thats too big, please enter cards 1 to 10");
  214.  }
  215.  else printf("\nplayer 1 has a card thats too big, please enter cards 1 to 10");
  216.  }
  217.    else printf("player 2 has less than 2 cards, please introduce more values"); /* if card amount is bigger than 10 shows this message*/
  218.    }   
  219.    else printf("player 2 has more than 10 cards, please choose a lower value");/* if card amount is bigger than 10 shows this message*/
  220. }
  221.    else printf("player 1 has less than 2 cards, please introduce more values");
  222.    /* if card amount is bigger than 10 shows this message*/
  223.    }   
  224.    else printf("player 1 has more than 10 cards, please choose a lower value")/* if card amount is bigger than 10 shows this message*/
  225.    
  226. }