Using dynamic multi-dimensional arrays in c++

后端 未结 6 520
礼貌的吻别
礼貌的吻别 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:35

    You forgot to allocate memory for second dimension of the matrix.

    int **lsquare;
    lsquare = new int*[n];
    for (int i=0; i

    nobody writes

    for (int i=0;i<=n-1;i++){...}
    

    Do instead

    for (int i=0; i

提交回复
热议问题