Using dynamic multi-dimensional arrays in c++

后端 未结 6 526
礼貌的吻别
礼貌的吻别 2020-12-21 01:24

I am making a C++ program that checks if given aray is a latin square. I need to use a dynamic multi-dimensional array that stores given latin square. But I cant pass the ar

6条回答
  •  死守一世寂寞
    2020-12-21 01:46

    To be able to do that.. You actually need to do this:

    int **lsquare = new int*[n];
    
    for (int i=0; i> lsquare[i][j];
    
    blocktest(lsquare,n,sum);
    

    The better system would be to do:

    int *lsquare = new int[n*n];
    
    for (int i=0; i> lsquare[i + j*n];
    
    blocktest(lsquare, n, sum);
    

提交回复
热议问题