<mosaic.cnfolio.com>
PROGRAM
  1. /* START
  2.    Initialise the amount of cards Player1 has to 0
  3.    Obtain input value for the amount of cards for Player1
  4.    Display the input value for the amount of cards for Player1 
  5.    IF the obtained input value is less than 2
  6.       THEN
  7.           Display ERROR, the amount of cards Player1 has must be bigger than 2
  8.       ELSE
  9.           IF the obtained input value is more than 10
  10.             THEN
  11.                 Display ERROR, the amount of cards Player1 has must be less than 11
  12.         END IF
  13.     END IF
  14.        
  15.     There are 10 elements within the array for the type of cards player1 has
  16.        WHILE the number of cards player1's has is more than 0
  17.             Obtain input value for the type of cards for player1
  18.           IF the obtained input value is less than 1
  19.            THEN
  20.                Display ERROR, type of cards Player1 has must be bigger than 0
  21.             ELSE
  22.                  IF the obtained input value is more than 10
  23.                     THEN
  24.                         Display ERROR, type of cards Player1 has must be less than 11
  25.                 END IF
  26.            END IF
  27.         END WHILE
  28.     Player1's cards are then ordered from descending order
  29.     Display all cards player1 has obtained
  30.    
  31.     Initialise the amount of cards Player2 has to 0
  32.     Obtain input value for the amount of cards for Player2
  33.     Display the input value for the amount of cards for Player2 
  34.     IF the obtained input value is less than 2
  35.        THEN
  36.            Display ERROR, the amount of cards Player2 has must be bigger than 2
  37.        ELSE
  38.            IF the obtained input value is more than 10
  39.               THEN
  40.                   Display ERROR, the amount of cards Player2 has must be less than 11
  41.             END IF
  42.     END IF
  43.        
  44.     There are 10 elements within the array for the type of cards player2 has
  45.        WHILE the number of cards player2's has is more than 0
  46.             Obtain input value for the type of cards for player2
  47.           IF the obtained input value is less than 1
  48.            THEN
  49.                Display ERROR, type of cards Player2 has must be bigger than 0
  50.             ELSE
  51.                  IF the obtained input value is more than 10
  52.                     THEN
  53.                         Display ERROR, type of cards Player2 has must be less than 11
  54.                 END IF
  55.            END IF
  56.         END WHILE
  57.     Player2's cards are then ordered from descending order
  58.     Display all cards player2 has obtained
  59.    
  60.     Initialise the minimum card amount to equal the number of cards player 1 has
  61.                IF the number of cards player2 has is smaller than the minimum card amount
  62.                   THEN
  63.                       initalise minimum card amount to equal the number of cards player 2 has
  64.                END IF         
  65.     WHILE 10 is more than 0         
  66.         IF player1's cards are bigger than player2's cards
  67.             THEN
  68.                 Display Player1 wins!
  69.             ELSE
  70.                 IF player2's cards are bigger than player1's cards
  71.                    THEN
  72.                        Display Player2 win
  73.                     ELSE
  74.                         IF both player1's and player2's cards are equal
  75.                            THEN
  76.                                Display It's a draw!
  77.                         END IF
  78.                 END IF
  79.         END IF
  80.     END WHILE
  81. END         
  82. */
  83.  
  84.  
  85.  
  86. #include <stdio.h>
  87. #include <stdlib.h>
  88.  
  89. int main(void) {
  90.  
  91.     char *a = "Player1";
  92.     char *b = "Player2";
  93.  
  94.     int P1noCards = 0;
  95.     scanf("%d", &P1noCards);
  96.     printf("%d\n", P1noCards);       
  97.  
  98.     if (P1noCards < 2) {// Values entered must be between 2 & 10 or error message will appear// 
  99.         printf("ERROR, the amount of cards Player1 has must be bigger than 1\n");
  100.         return 0;
  101.     } else if (P1noCards > 10) {
  102.         printf("ERROR, the amount of cards Player1 has must be less than 11\n");
  103.         return 0;
  104.     }
  105.              
  106.     int P1cards[10]; // asking to give 10 bits of memory to this array//
  107.     int i, j, temp; 
  108.  
  109.     for (i=0; i<P1noCards; i++) { //loop begins when i=0, ends when i<P1noCards and i goes up in 1//
  110.        scanf("%d", &P1cards[i]);
  111.         if (P1cards[i] < 1) {
  112.             printf("ERROR, type of cards Player1 has must be bigger than 0\n");
  113.             return 0;
  114.         } else if (P1cards[i] > 10) {
  115.             printf("ERROR, type of cards Player1 has must be less than 11\n");
  116.             return 0;
  117.         }
  118.     }
  119.  
  120.     for (i=0; i<P1noCards; i++) {// bubble sort//
  121.         for(j=i+1; j<P1noCards; ++j) {// j has to be one infront of i, in-order to compare the values//
  122.             if(P1cards[j]>P1cards[i]) {
  123.                 temp=P1cards[i];
  124.                 P1cards[i]=P1cards[j];
  125.                 P1cards[j]=temp;
  126.             }
  127.         }
  128.     }
  129.            
  130.     for(i=0; i<P1noCards; ++i){
  131.         printf("%d ",P1cards[i]);
  132.     }
  133.     printf("\n");
  134.  
  135.    
  136.     int P2noCards = 0;    // essentially this is the same as P1, but only for P2 now//
  137.         scanf("%d", &P2noCards);
  138.         printf("%d\n", P2noCards);       
  139.    
  140.     if (P2noCards < 2){
  141.         printf("ERROR, the amount of cards Player2 has must be bigger than 1\n");
  142.         return 0;
  143.     } else if (P2noCards > 10) {
  144.         printf("ERROR, the amount of cards Player2 has must be less than 11\n");
  145.         return 0;
  146.     }
  147.      
  148.     int P2cards[10];
  149.     for (i=0; i<P2noCards; i++) {       
  150.         scanf("%d", &P2cards[i]);
  151.          if (P2cards[i] < 1) {
  152.             printf("ERROR, type of cards Player2 has must be bigger than 0\n");
  153.             return 0;
  154.         } else if (P2cards[i] > 10) {
  155.             printf("ERROR, type of cards Player2 has must be less than 11\n");
  156.             return 0;
  157.         }
  158.     }
  159.     //Bubble sort//
  160.     for (i=0; i<P2noCards; i++) {
  161.         for(j=i+1; j<P2noCards; ++j) {
  162.             if(P2cards[j]>P2cards[i]) {
  163.                 temp=P2cards[i];
  164.                 P2cards[i]=P2cards[j];
  165.                 P2cards[j]=temp;
  166.             }
  167.         }
  168.     }
  169.    
  170.     for(i=0; i<P2noCards; ++i) {
  171.         printf("%d ",P2cards[i]);
  172.     }
  173.     puts("\n");
  174.        
  175.     int MinCardAmount = P1noCards; // This is so that when the players get different amount of cards, the program would only view the lowest amount of cards//
  176.     if (P2noCards < MinCardAmount) { // to start off we could say that the minimum card amount is equal to P1/P2nocards//
  177.         MinCardAmount = P2noCards; // and if the number of cards is smaller than the minimum amount, that then becomes the minimum//
  178.     } // This so that it would compare the same amount of cards//
  179.  
  180.    for(i=0; i<10; i++){             // for each pair that is compared, it should say who wins or if it's a draw//
  181.     if (P1cards[i] > P2cards[i]){   // if it's a draw it would, display draw then give results for next pair of values//
  182.         printf("%s wins!\t", a);
  183.         return 0
  184.     }else if (P1cards[i] < P2cards[i]){
  185.         printf("%s wins!\t", b);
  186.         return 0;       
  187.     }else if (P1cards[i] == P2cards[i]){
  188.         printf("It's a draw!\t");
  189.  
  190.       }
  191.     }     
  192. }