我试图在Latin Square Daily Challenge on Reddit,我想用用下面的代码在运行时,其分配大小的数组:2-d阵列 - 表达必须有一个恒定值误差
int n;
cout << "Please enter the size of the Latin Square: ";
cin >> n;
int latinsquare[n][n];
该作品在在线编译器中,而不是在Visual Studio 17中。有没有办法在Microsoft C++编译器中执行此操作?
这是有见地的干杯!它按预期工作,但为什么在这段代码“latinsquare(n,std :: vector(n,0))'''中为'0'而不是'n'?此外,听起来可能有点傻,但我怎么会输出这两个阵列内的矢量?谢谢 –
LiamJM
@LiamJM Zero是分配给矢量的每个元素的值,作为其初始化的一部分。输出数组需要两个嵌套循环。 – dasblinkenlight