How to create 2d array c++?

后端 未结 5 2053
无人共我
无人共我 2020-12-10 21:05

I need to create 2d array in c++.

I can\'t do it by int mas= new int[x][y]; or auto mas= new int[x][y]; I need to create an array dynamical

5条回答
  •  天涯浪人
    2020-12-10 21:30

    You can do the manipulations yourself.

    int* mas = new int[x*y];
    

    and access [i,j] by:

    mas[i*y + j] = someInt;
    otherInt = mas[i*y +j];
    

提交回复
热议问题