mercredi 7 octobre 2015

How to create a random shuffle from 2D array

Im trying to create a random function from a given 2d array. The code should be able to shuffle cards based on information in array.

string DeckCards [6][6] = ///determine size of deck //deck1
{

    {"1A", "1B", "1C", "1D", "2A", "2B"},
    {"2C", "2D", "3A", "3B", "3C", "3D"},
    {"4A", "4B", "4C", "4D", "1A", "1B"},
    {"1C", "1D", "2A", "2B", "2C", "2D"},
    {"3A", "3B", "3C", "3D", "4A", "4B"},
    {"4C", "4D", "  ", "  ", "  ", "  "}

};

void randomize(string DeckCards[6][6],int n)
{
    srand( time(NULL) );
    for(int i = n-1; i > 6; i--)
    {
        int j = rand() %(4+1);
        swap(&DeckCards[i],[j]);
    }
}

the error is too large to include




Aucun commentaire:

Enregistrer un commentaire