Program background:

I'm trying to simulate a 6-deck blackjack shoe, but only running through the first 3 decks; casinos shuffle at any point after the halfway, so I'm just assuming they shuffle immediately at the halfway.

I'm trying to use the array deck to store each card (and I'm ignoring suit, so each card is merely 1-13). Array cardcheck's purpose is to hold how many of each card I've already used; in a 6-deck shoe, there are only 24 of each card, and randomly filling in each card slot, I have to check for each card that there are not already 24 of that card. If I were filling all 312 card slots, this would be inefficient as the deck approached full; however, because half the deck will remain unfilled, it will not have too many conflicts before picking an acceptable value.



As it stands, the program is only supposed to generate a random deck and then output each card value on a separate line. The problem so far is I have not gotten the values expected; quite the contrary, running the program I get an alarming number of repetitive cards, and the values run far beyond the thousands in either direction.

I'm sorry for not commenting my program well, I'm very new to coding.


Without further ado, here's the program so far:

Code:
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

const int LOW = 1;
const int HIGH = 13;

int main()

{

int deck[156];

int cardcheck[13];

time_t seconds;
    time(&seconds);
    srand((unsigned int) seconds);

for(int x=0;x<13;x++)
{
cardcheck[x]=0;
}

for(int x=0;x<156;x++)  // creates a 6 deck shoe, for first half of shoe
    {
    
    int newcard;
    
    newcard = rand() % (HIGH - LOW + 1) + LOW;  // creates random value in newcard
    
    if(cardcheck[newcard] < 24)
    {
     ++cardcheck[newcard];
     deck[x] = newcard;
    }
    else
    {
      x = x-1;    
    }
    
    for(int y=0;y<156;y++)
    {
    printf("%d \n", deck[y]);
    
    }
    
    }




}

My question boils down to, what is wrong with this? Further, are there any better ways to randomly fill in a set of values, where each value can only be used a certain number of times? Any help would be greatly appreciated!