私は最初の一番上の行と一番下の行を塗りつぶします どうすればこのことができますか?これまでのところ:この場合C++ 2D配列の塗りつぶしのみ上の行と下の行
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
*/
}
}
は:私たちはいくつかのいずれかが
を。グリッド[行-1] [j] = 1; } – user1438832