<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.   Declare integer array for player1 and player2
  4.   Declare integer for variables m, n,i,j,tmp,x
  5.   Declare integer for cards and SET to zero
  6.   GET player 1 card number in hand and SET to m variable
  7.     IF input card number in hand less than two or greater than ten
  8.        THEN display ERROR message
  9.        RETURN to start of program
  10.     END IF
  11.   SET i variable to zero and REPEAT as long as i variable is less than m and increment i  variable
  12.   GET values and set to array player1
  13.     IF input card numbers value less than one or greater than ten
  14.        THEN display ERROR message   
  15.        RETURN to start of program
  16.     END IF
  17.    END REPEAT
  18.   GET player 2 card number in hand and SET to n
  19.     IF input card number in hand less than two or greater than ten
  20.        THEN display ERROR message
  21.        RETURN to start of program
  22.     END IF
  23.     SET i variable to zero and REPEAT as long as i variable is less than n variable and increment i                       variable
  24.    GET card values and set to array player2
  25.     IF input card number value less than one or greater than ten
  26.          THEN display ERROR message
  27.          RETURN to start of program
  28.     END IF
  29.   END REPEAT
  30.    Get all numbers to sort for player 1
  31.    Set the position number to zero
  32.    WHILE the position number is one less than the quantity of numbers to sort
  33.          Look in all positions lower than the current position to find the highest number
  34.          Swap the highest number and the number at the current position
  35.          Increase the position number by one
  36.    END WHILE
  37.     Get all numbers to sort for player 2
  38.     Set the position number to zero
  39.    WHILE the position number is one less than the quantity of numbers to sort
  40.          Look in all positions lower than the current position to find the highest number
  41.          Swap the highest number and the number at the current position
  42.          Increase the position number by one
  43.     END WHILE     
  44.     SET x variable to zero and REPEAT as long as x variable is less than ten and increment x variable
  45.        IF array player 1 card number bigger than array player2 card number in a turn
  46.                   AND array player1 card number less than eleven
  47.                    AND array player2 card number less than eleven
  48.          THEN display player 1 wins
  49.          RETURN to start of program
  50.     END IF
  51.     IF array player2 card number bigger than array player1 card number in a turn
  52.                   AND array player1 card number less than eleven
  53.                    AND array player2 card number less than eleven
  54.          THEN display player 2 wins
  55.          RETURN to start of program
  56.      END IF
  57.     IF array player1 list of card numbers equal to list of card numbers for array  player2
  58.                     AND m variable equals n variable
  59.      Increment cards
  60.             IF m variable is equal to cards OR n variable equals to card
  61.                   THEN display draw
  62.                    RETURN to start of program
  63.             END IF
  64.     END IF
  65.   END REPEAT
  66.  
  67. END */
  68.  
  69. #include <stdio.h>
  70.  
  71. int main ()
  72.  
  73. {
  74.   int player1[10], player2[10];                                    //arrays for player 1 n 2
  75.   int m,n,i,j,tmp,x;                                               // declared variables
  76.   int cards=0;                                                     // declare variable= 0
  77.  
  78.  
  79.   scanf("%d", &m);                                                //input data for number of cards for player 1
  80.  
  81.   if(m<2 || m>10){                                                // input data to be in between 2 and 10 for player 1
  82.   printf(" ERROR,PLAYER 1 ENTER NUMBER BETWEEN 2 TO 10:", m);     // display error message if not betwween 2 to 10
  83.   return ;}                                                       // return to beginning if not between 2 to 10
  84.  
  85.   for (i = 0; i < m; i++)                                         // array condition for player 1
  86.   {
  87.    scanf("%d", &player1[i]);                                      // input data for card numbers for player 1 and save in player1[i]
  88.    if(player1[i]<1 ||player1[i]>10){                              //player card values between 1 and 10
  89.    printf(" Player 1 Enter CARD NUMBERS btw 1 to 10");            // print error message for player 1 if card value input not betwwen 1 to 10
  90.    return;}
  91.    
  92.  
  93.  
  94.   }
  95.  
  96.  
  97.   scanf("%d", &n);                                             //input data for number of cards for player 2
  98.  
  99.   if(n<2 || n>10){                                             // input data to be in between 2 and 10 for player 2
  100.   printf(" ERROR,PLAYER 2 ENTER NUMBER BETWEEN 2 TO 10:", n);   // display error message if not betwween 2 to 10
  101.   return ;}                                                       // return to beginning if not between 2 to 10
  102.   for (i = 0; i < n; i++)                                   
  103.   {
  104.    scanf("%d", &player2[i]);                                   // input data for card numbers for player 2 and save in player2[i]
  105.    if(player2[i]<1 ||player2[i]>10){                              // player card values betwwen 1 to 10
  106.    printf("\n Player 2 Enter CARD NUMBERS btw 1 to 10");          // show error message if player values not between 1 to 10
  107.    return;}
  108. }   
  109. /* SORTING CARDS NUMBER FOR PLAYER 1 */                           // sort card number s in descending order for player 1
  110.         for (i=0; i<m; i++)
  111.   {
  112.         for(j=i+1; j<m; j++)
  113.         {
  114.             if(player1[i] < player1[j])
  115.             {
  116.                 tmp = player1[i];
  117.                 player1[i] = player1[j];
  118.                 player1[j] = tmp;
  119.             }
  120.         }
  121.     }
  122.   for(i=0; i<m; i++)
  123.     { }
  124.  /* SORTING CARDS NUMBERS FOR PLAYER 2 */                       // sorting card number in descending order for player 2
  125.         for (i=0; i<n; i++)
  126.   {
  127.         for(j=i+1; j<n; j++)
  128.         {
  129.             if(player2[i] < player2[j])
  130.             {
  131.                 tmp = player2[i];
  132.                 player2[i] = player2[j];
  133.                 player2[j] = tmp;
  134.             }
  135.         }
  136.     }
  137.    for(i=0; i<n; i++){    }         
  138.  /* COMPARING CARD NUMBERS FOR PLAYER 1 AND 2 THEN DECLARE WINNER */
  139.   for(x=0; x<10; x++){                                            //loop for comparing player 1 and player 2 card values   
  140.   if(player1[x]>player2[x] && player1[x]<11 && player2[x]<11){    //conditions for player 1 to win
  141.    printf("PLAYER 1 WINS");
  142.    return;}     
  143.   if(player2[x]>player1[x] && player1[x]<11 && player2[x]<11 ){   //condition for player 2 to win
  144.    printf("PLAYER 2 WINS.");
  145.   return;}
  146.   if(player1[x]==player2[x] && m==n){                             // conditions for draw
  147.   cards++;
  148.   if(m==cards || n==cards){
  149.  printf("DRAW.");
  150.   return;}
  151.   }
  152.   }
  153.  }