vector<vector<Point>>
时间: 2023-09-25 10:14:50 浏览: 101
vector<vector<Point>>是一个二维的动态数组,其中每个元素是一个Point类型的向量。你可以通过使用vector类来创建和操作它。例如,你可以使用push_back函数将一个Point向量添加到vector<vector<Point>>中。你还可以使用下标或迭代器来访问和遍历这个二维数组的元素。请参考以下代码示例:
```cpp
#include <iostream>
#include <vector>
using namespace std;
struct Point {
int x, y;
};
vector<vector<Point>> points;
int main() {
vector<Point> p1;
Point d1;
d1.x = 1;
d1.y = 2;
p1.push_back(d1);
vector<Point> p2;
Point d2;
d2.x = 3;
d2.y = 4;
p2.push_back(d2);
points.push_back(p1);
points.push_back(p2);
cout << "Number of rows: " << points.size() << endl;
cout << "Number of columns in the first row: " << points<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [C++ 中vector的使用方法](https://blog.csdn.net/qq_34600424/article/details/79752815)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文