kann jemand bitte helfen Sie mir, dies zu tun Ich möchte nur die obere Zeile zuerst und dann die untere Zeile ausfüllen Wie kann ich das tun dies ist, was ich habe so weit:C++ 2D-Array füllen nur obere Zeile dann untere Zeile
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
*/
}
}
in diesem Fall: damit kann sagen, dass wir nicht wissen, die Anzahl der Zeilen und Spalten ich bin ein Anfänger in C++ und Arrays bitte, wenn jemand
für (int j = 0; j
user1438832