<mosaic.cnfolio.com>
PROGRAM
  1. #include <time.h>
  2.  
  3.  
  4. void main()
  5. { /*this ensure that the RNG is random after multiply play throughs*/
  6.    srand(time(0));
  7.    /*this creates the size of the decks between 2-10*/
  8.    int player1[rand() % (10 + 1 - 2) + 2];
  9.    int player2[rand() % (10 + 1 - 2) + 2];
  10.    
  11.    /*counter for both decks*/
  12.    int listMarker=1;
  13.    int biggestV1=1;
  14.    int NextV=2;
  15.    int biggestV2=1;
  16.    int sumLen1;
  17.    int sumLen2;
  18.    int winner = 0;
  19.    
  20.    
  21.    /*this give the length of the decks*/
  22.    int num1=sizeof(player1)/sizeof(player1[0]);
  23.    int num2=sizeof(player2)/sizeof(player2[0]);
  24.    sumLen1=num1;
  25.    sumLen2=num2;
  26.    
  27.    /*prints which player owns this deck*/
  28.    printf("player1 ");
  29.    
  30.    /*prints how long this is deck*/
  31.    printf("\n%d\n",sumLen1);
  32.    
  33.    RNG( sumLen1, listMarker,  player1 );
  34.            
  35.    
  36.    sumLen1=num1;
  37.      
  38.    /*finds the largest card in the players deck*/
  39.    while (sumLen1 >= NextV){
  40.       if (player1[biggestV1]>=player1[NextV]){
  41.          NextV=NextV+1;
  42.       }
  43.       else if (player1[biggestV1]<player1[NextV]){
  44.          biggestV1=NextV;
  45.          NextV=NextV+1;
  46.       }
  47.            
  48.    }
  49.          
  50.    
  51.    /*prints which player owns this deck*/
  52.    printf("\nplayer2 ");
  53.    
  54.    /*prints how long this is deck*/
  55.    printf("\n%d\n",sumLen2);
  56.    
  57.    /*this populates the deck with random numbers*/
  58.    RNG( sumLen2, listMarker,  player2 );
  59.    
  60.      
  61.    sumLen2=num2;
  62.    /*finds the largest card in the players deck*/
  63.    while (sumLen2 >= NextV){
  64.       if (player2[biggestV2]>=player2[NextV]){
  65.          NextV=NextV+1;
  66.       }
  67.       else if (player2[biggestV2]<player2[NextV]){
  68.          biggestV2=NextV;
  69.          NextV=NextV+1;
  70.       }
  71.            
  72.    }
  73.  
  74.  while(winner == 0){
  75.  
  76.       
  77.      
  78.      
  79.      
  80.      
  81.       if (player1[biggestV1]>player2[biggestV2]){     
  82.       winner = 1;
  83.       printf("\nplayer 1 is the winner");
  84.       }
  85.       else if (player2[biggestV2]>player1[biggestV1]){
  86.       winner = 1;
  87.       printf("\nplayer 2 is the winner");
  88.       }
  89.       /*need to add a bit that removes the current biggest value from the decks*/
  90.       /*need to slit the programe up into separate modules*/
  91.       else if (player2[biggestV2]==player1[biggestV1]){
  92.       winner = 1;
  93.       printf("\ndraw");
  94.       }
  95.    }
  96.  
  97. }
  98.  
  99. int RNG(int a,int b, int array_variable[] ){
  100.    while (a > 0){
  101.       a=a-1;
  102.       array_variable[b] = rand() % (10 + 1 - 1) + 1;
  103.       printf("%d ",array_variable[b]);
  104.       b=b+1;
  105.    }
  106. }
  107. /*determines the winner by who has the largest card*/