有人可以帮我做到这一点 我想只填写第一行然后是最后一行 我怎么能这样做这就是我所拥有的到目前为止:C++二维数组填充只有顶行然后底行
const int rows = 2;
const int columns = 6;
int grid[rows][columns] = { 0 }; /* 0 0 0 0 0 0
0 0 0 0 0 0
*/
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
grid[i][j] = 1; //fill the top row only
/* Output:
1 1 1 1 1 1
0 0 0 0 0 0
*/
}
}
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
grid[i][j] = 2; //fill the bottom row only
/* Output:
1 1 1 1 1 1
2 2 2 2 2 2
*/
}
}
在这种情况下:可以说,我们不知道阵列请,如果有人可以帮助
对(INT J = 0;Ĵ<列; J ++){ 网格 [0] [j] = 1; grid [row-1] [j] = 1; } – user1438832