#include <cstdio>
#include <cstdlib>
#include <ctime>

int main(){
    int n=4; // Number of players
    int bet[n]; // Bet of each player
    int digit[n][4];   // Each player has 4 digits
    int pay=20;        // bet of each game
    int i,j,k;
    bool game_end=false;    // Indicate whether the game ends
    bool same4,same3; 
    bool parity;   // Store whether all of them are odd or even.            
    bool prime;    // Store whether all are primes.
    bool z;
    
    int bonus;     // Returned bonus at each round
    
    
    srand(time(0));
    for (i=0;i<n;++i) bet[i]=500;
    
    while (!game_end){
          
          // Gives each player 4 digits from 0 to 9
          for (i=0;i<n;++i) 
          for (j=0;j<4;++j) digit[i][j]=rand()%10;
          
          // For each player k-th, check all the rules 
          for (k=0;k<n;++k){
          bonus=0;  // Before checking there is no bonus

          // Check whether 4 are the same
          same4=true;
          for (i=0;i<3;++i) 
          same4=same4 && (digit[k][i]==digit[k][i+1]);
          //if (same4) same4=digit[k][i]==digit[k][i+1];
          
          
          // Check for odd or even parity
          parity=true;
          for (i=0;i<3;++i)
          parity=parity && (digit[k][i]%2==digit[k][i+1]%2);
          
          // Check for all primes.
          prime= true ;
          for ( i=0 ; i<4 ; ++i )  // Check all digits
              // If the previous all are prime
              // We proceed to check the next one
               if (prime) { 
                         z=true;
                         for ( j=2 ; j<=digit[k][i]-1 ; ++j )                    
                             if ( digit[k][i]%j==0 ) z=false;
                         prime = z ; 
                         }
          
          
          
          if (same4) bonus+=100; // 100% for all the same
          //Otherwise we proceed to check for 3 are the same
          
          
          }
    }

    return 0;   
}

