c++ - C++11: 生成动态的二位数组

devcpp

2018-06-08T07:38:26Z||2018-06-08T07:38:26Z

int width = 5;
int height = 2;

vector<vector<int>> matrix(height, vector<int>(width, -1));

for (auto rows: matrix) {
    for (auto col: rows) {
        cout << col << " ";
    }
    cout << endl;
}

特么一行有木有。特么代码很好看有木有。