vector<vector<pair<int,int>>>
时间: 2023-10-22 21:20:29 浏览: 123
vector
This is a vector of vectors, where each element of the outer vector is a vector of pairs of integers.
For example,
```c++
vector<vector<pair<int,int>>> v;
```
creates an empty vector of vectors. To add a vector of pairs to this, we can do:
```c++
vector<pair<int,int>> inner; // create an inner vector
inner.push_back(make_pair(1,2)); // add a pair to the inner vector
inner.push_back(make_pair(3,4)); // add another pair to the inner vector
v.push_back(inner); // add the inner vector to the outer vector
```
Now, `v` contains one vector of pairs:
```
v = [
[(1,2), (3,4)]
]
```
We can add more vectors of pairs to `v` in a similar way.
This data structure is useful for storing a collection of pairs where each pair belongs to a different group or category. For example, if we are storing the grades of students in a class, we can have a vector for each subject and each vector contains pairs of (student_id, grade).
阅读全文