lundi 9 décembre 2019

How to randomize 2d array in C

    for (int i = 0; i < 3; i++)  
{
    int r = rand() % 3;
    for (int j = 0; j < 3; j++)
    {
        int temp = mati[i][j];
        mati[i][j] = mati[r][j];
        mati[r][j] = temp;
    }
}

Here I have a 2d array named mati and I want to randomize its elements but ı dont know how ?




Aucun commentaire:

Enregistrer un commentaire