mardi 10 décembre 2019

How can I optimize mirroring of matrix function

int i,j;
int m=0;
int r=0;
int matrix1[rows][cols];

    for(i = 0; i < rows; i++)
    {
        m=0;
        for(j = cols-1; j >= 0; j--)
        {
            matrix1[i][m++] = matrix[i][j];
        }
    }
    for(i = 0; i < rows; i++)
    {
        for(j = 0; j <cols; j++)
        {
            matrix[i][j]=matrix1[i][j];
        }
    }

Let's say matrix array has already initialized. Can you mirror it in without assign to the new matrix?





Aucun commentaire:

Enregistrer un commentaire