我需要帮助了解如何嵌套for循环在C++以及如何理解正在发生什么?嵌套循环如何工作?
有人能向我解释是怎么回事用这些代码:
#include <iostream>
using namespace std;
int main() {
const int MAX_ROWS = 3;
const int MAX_COLS = 4;
// 2D array of integers
int MyInts[MAX_ROWS][MAX_COLS] = {{34, -1, 879, 22},
{24, 365, -101, -1},
{-20, 40, 90, 97}};
// iterate rows, each array of int
for (int Row = 0; Row < MAX_ROWS; ++Row) {
// iterate integers in each row (columns)
for (int Column = 0; Column < MAX_COLS; ++Column) {
cout << "Integer[" << Row << "][" << Column << "] = " << MyInts[Row][Column] << endl;
}
}
return 0;
}
我怎么教自己什么三重嵌套的for循环是干什么的?
此代码来自一本书,但我想知道更多关于它 – user3126681
我建议你通过一些基本的教程。 – Maroun