<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. Start
  3.  
  4. INITIALIZE arrays of 10 integers for Player1 and Player2
  5.  
  6. SET variables 'i', 'j', and 'PlayerValues' as INTEGERS
  7. ============================================================================
  8. OBTAIN   INPUT  ASSIGN to 'i'
  9.  
  10.          IF  INPUT for 'i' is less than 2 or greater than 10
  11.          
  12.                THEN  DISPLAY "Has to be in the range of 2 to 10"
  13.                
  14.                END PROGRAMME
  15.                
  16.          END IF
  17.  
  18. FOR      Firt position of PlayerValues to last position of PlayerValues
  19.          
  20.          OBTAIN      VALUE of cards ASSIGNED to array Player1[PlayerValues]
  21.          
  22.                IF  Player1[PlayerValues] is less than 1 or greater than 10
  23.                      
  24.                      THEN  DISPLAY "Has to be in the range of 1 to 10
  25.                      
  26.                      END PROGRAMME
  27.                      
  28.                END IF
  29.                
  30. END FOR
  31. ============================================================================
  32. OBTAIN   INPUT  ASSIGN to 'j'
  33.  
  34.          IF  INPUT for 'j' is less than 2 or greater than 10
  35.          
  36.                THEN  DISPLAY "Has to be in the range of 2 to 10"
  37.                
  38.                END PROGRAMME
  39.                
  40.          END IF
  41.  
  42. FOR      Firt position of PlayerValues to last position of PlayerValues
  43.          
  44.          OBTAIN      VALUE of cards ASSIGNED to array Player2[PlayerValues]
  45.          
  46.                IF  Player2[PlayerValues] is less than 1 or greater than 10
  47.                      
  48.                      THEN  DISPLAY "Has to be in the range of 1 to 10
  49.                      
  50.                      END PROGRAMME
  51.                      
  52.                END IF
  53.                
  54. END FOR
  55. ============================================================================
  56. OBTAIN   INPUT  ASSIGN to array locations 'Player1[0], 'Player1[1]', 'Player1[2]', 'Player1[3]', 'Player1[4]', 'Player1[5]', 'Player1[6]', 'Player1[7]', 'Player1[8]', 'Player1[9]'
  57.       
  58. SET variable numberOfValues1 to hold 'i'
  59.          
  60. SET variable 'outside1', 'inside1', 'highest1', 'SwapValues1' as INTEGERS
  61.          
  62. FOR      First position of 'outside1' to the position of 'outside1' less than 'numberOfValues1'
  63.  
  64.          SET variable 'highest1' to hold 'outside1'
  65.          
  66.          FOR      first position of 'inside1' to the position of 'inside1' less than numberOfValues1
  67.                   
  68.                   IF  'Player1[inside1]' is bigger than Player1[highest1]
  69.                  
  70.                         SET variable highest1 to hold inside1
  71.                        
  72.                         swap values 'Player1[outside1]' with 'Player1[highest1]' using variable 'SwapValues1'
  73.                        
  74.                   END IF
  75.                  
  76.          END FOR
  77.          
  78. END FOR
  79. ============================================================================   
  80. OBTAIN   INPUT  ASSIGN to array locations 'Player2[0], 'Player2[1]', 'Player2[2]', 'Player2[3]', 'Player2[4]', 'Player2[5]', 'Player2[6]', 'Player2[7]', 'Player2[8]', 'Player2[9]'
  81.       
  82. SET variable numberOfValues2 to hold 'j'
  83.          
  84. SET variable 'outside2', 'inside2', 'highest2', 'SwapValues2' as INTEGERS
  85.          
  86. FOR      First position of 'outside2' to the position of 'outside2' less than 'numberOfValues2'
  87.  
  88.          SET variable 'highest2' to hold 'outside2'
  89.          
  90.          FOR      first position of 'inside2' to the position of 'inside2' less than numberOfValues2
  91.                   
  92.                   IF  'Player2[inside2]' is bigger than Player2[highest2]
  93.                  
  94.                         SET variable highest2 to hold inside1
  95.                        
  96.                         swap values 'Player2[outside2]' with 'Player2[highest2]' using variable 'SwapValues2'
  97.                        
  98.                   END IF
  99.                  
  100.          END FOR
  101.          
  102. END FOR   
  103. ============================================================================ 
  104. SET variable 'k' as an INTEGER
  105.  
  106. FOR      first position of 'k' to the position of 'k' less than 10
  107.  
  108.          IF  'Player2[k]' is bigger than 'Player1[k]'
  109.          
  110.                DISPLAY  "Player 2 wins"
  111.                
  112.                END PROGRAMME
  113.                
  114.          END IF
  115.          
  116.          ELSE
  117.          
  118.          IF  'Player1[k]' is bigger than 'Player2[k]'
  119.          
  120.                DISPLAY  "Player 1 wins"
  121.                
  122.                END PROGRAMME
  123.                
  124.          END IF
  125.          
  126.          ELSE
  127.          
  128.          IF  'Player1[k]' is equivalent to 'Player2[k]'
  129.          
  130.                MINUS 1 from INTEGER 'i'
  131.                MINUS 1 from INTEGER 'j'
  132.                
  133.                IF  INTEGER 'i' is equivalent to 0 or INTEGER 'j' is equivalent to 0
  134.                
  135.                      IF  INTEGER 'i' is bigger than INTEGER 'j'
  136.                      
  137.                            DISPLAY "Player 1 wins"
  138.                            
  139.                            END PROGRAMME
  140.                            
  141.                      END IF
  142.                      
  143.                      IF  INTEGER '' is bigger than INTEGER 'i'
  144.                      
  145.                            DISPLAY "Player 2 wins"
  146.                            
  147.                            END PROGRAMME
  148.                            
  149.                      END IF
  150.                      
  151.                      IF  INTEGER 'i' is equivalent to INTEGER 'j'
  152.                      
  153.                            DISPLAY "draw"
  154.                            
  155.                            END PROGRAMME
  156.                            
  157.                      END IF
  158.                      
  159.                END IF
  160.                
  161.         END IF
  162.        
  163. END FOR
  164.  
  165. END PROGRAMME
  166. */
  167.  
  168. #include <stdio.h>
  169.  
  170.  
  171. int main(void)
  172.  
  173.  
  174. {
  175.  
  176.    int i, j;
  177.    
  178.    int Player1[10], Player2[10];       /*Array of 10 integers for Player1 and Player2*/
  179.    
  180.    int PlayerValues;
  181.  
  182.    /*Player1 rules*/
  183.    
  184.    scanf("%d", &i);
  185.    
  186.    if(i < 2||i > 10)
  187.    
  188.    {printf("Has to be in the range of 2 to 10");return;}
  189.    
  190.    for(PlayerValues = 0; PlayerValues < i; PlayerValues++)      /*First position of 'i' to last position of 'i'*/
  191.    
  192.    {
  193.    
  194.       scanf("%d", &Player1[PlayerValues]);         /*Input goes into Player1 array*/
  195.    
  196.       if(Player1[PlayerValues] < 1|| Player1[PlayerValues] > 10)
  197.    
  198.       {printf("Has to be in the range of 1 to 10");return;}
  199.    
  200.    }
  201.    
  202.    /*Player2 rules*/
  203.    
  204.    scanf("%d", &j);
  205.    
  206.    if(j < 2||j > 10)
  207.    
  208.    {printf("Has to be in the range of 2 to 10");return;}
  209.    
  210.    for(PlayerValues = 0; PlayerValues < j; PlayerValues++)     /*First position of 'j' to last position of 'j'*/
  211.    
  212.    {
  213.    
  214.       scanf("%d", &Player2[PlayerValues]);         /*Input goes into Player2 array*/
  215.    
  216.       if(Player2[PlayerValues] < 1|| Player2[PlayerValues] > 10)
  217.    
  218.       {printf("Has to be in the range of 1 to 10");return;}
  219.    
  220.    }
  221.    
  222.    /*Player1 sort code*/
  223.    
  224.    scanf("%d %d %d %d %d %d %d %d %d %d", &Player1[0], &Player1[1], &Player1[2], &Player1[3], &Player1[4], &Player1[5], &Player1[6], &Player1[7], &Player1[8], &Player1[9]);
  225.    
  226.    int numberOfValues1 = i;
  227.    
  228.    int outside1, inside1, highest1, SwapValues1;
  229.    
  230.    /* start at the first number and looks at every number except the last number */
  231.  
  232.    for ( outside1 = 0; outside1 < (numberOfValues1 - 1); outside1++ )
  233.    
  234.    {
  235.      
  236.      /* during each round of sorting, start with the current number as the lowest number */
  237.      
  238.       highest1 = outside1;
  239.      
  240.       /* start at the next number after the current number and compare with every number */
  241.  
  242.       for (inside1 = (outside1 + 1); inside1 < numberOfValues1; inside1++ )
  243.      
  244.       if ( Player1[inside1] > Player1[highest1] ) highest1 = inside1;
  245.  
  246.       /* swap the position of the highest number found with the current number */
  247.      
  248.       SwapValues1 = Player1[outside1];
  249.      
  250.       Player1[outside1] = Player1[highest1];
  251.      
  252.       Player1[highest1] = SwapValues1;
  253.      
  254.    }
  255.    
  256.    /*Player2 sort code*/
  257.    
  258.    scanf("%d %d %d %d %d %d %d %d %d %d", &Player2[0], &Player2[1], &Player2[2], &Player2[3], &Player2[4], &Player2[5], &Player2[6], &Player2[7], &Player2[8], &Player2[9]);
  259.    
  260.    int numberOfValues2 = j;
  261.    
  262.    int outside2, inside2, highest2, SwapValues2;
  263.    
  264.    /* start at the first number and looks at every number except the last number */
  265.    
  266.    for ( outside2 = 0; outside2 < (numberOfValues2 - 1); outside2++ )
  267.    
  268.    {
  269.      
  270.       /* during each round of sorting, start with the current number as the lowest number */
  271.      
  272.       highest2 = outside2;
  273.      
  274.       /* start at the next number after the current number and compare with every number */
  275.  
  276.       for (inside2 = (outside2 + 1); inside2 < numberOfValues2; inside2++ )
  277.      
  278.       if ( Player2[inside2] > Player2[highest2] ) highest2 = inside2;
  279.  
  280.      
  281.       /* swap the position of the highest number found with the current number */
  282.      
  283.       SwapValues2 = Player2[outside2];
  284.      
  285.       Player2[outside2] = Player2[highest2];
  286.      
  287.       Player2[highest2] = SwapValues2;
  288.      
  289.    }
  290.    
  291.    /*End game result decider*/
  292.    
  293.    int k;
  294.    
  295.    for(k=0;k<10;k++)
  296.    
  297.    {
  298.    
  299.       if(Player2[k] > Player1[k])
  300.    
  301.       {printf("Player 2 wins");return;}
  302.    
  303.       else
  304.    
  305.       if(Player1[k] > Player2[k])
  306.    
  307.       {printf("Player 1 wins");return;}
  308.    
  309.       else
  310.    
  311.       if(Player1[k] == Player2[k])
  312.    
  313.       {
  314.    
  315.          i = i - 1;
  316.          j = j - 1;
  317.    
  318.          if(i==0||j==0)
  319.    
  320.          {
  321.    
  322.             if(i>j)
  323.    
  324.             {printf("Player 1 wins");return;}
  325.    
  326.             else
  327.    
  328.             if(j>i)
  329.    
  330.             {printf("Player 2 wins");return;}
  331.    
  332.             else
  333.    
  334.             if(i==j)
  335.    
  336.             {printf("draw");return;}
  337.    
  338.          }
  339.    
  340.       }
  341.    
  342.    }
  343.    
  344.    return;
  345.  
  346. }