Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void print(const vector<vector<int>> &mat);
- int main()
- {
- vector<vector<int>> mat;
- mat.resize(10);
- for (int i = 0; i < mat.size(); ++i)
- mat[i].resize(10);
- for (int i = 0; i < mat.size(); ++i)
- {
- for (int j = 0; j < mat[i].size(); ++j)
- {
- mat[i][j] = mat.size() * i + j + 1;
- }
- }
- // Here you can work with the "Matrix" (actually a multi-dimensional vector)
- //..
- //..
- //..
- // Print it for example
- cout << "print the original matrix:" << endl;
- print(mat);
- // Now I beleive, you want to delete a row
- mat.erase(mat.begin() + 1);
- // And now you can print it again
- cout << "print the matrix after we have deleted the second row" << endl;
- print(mat);
- return 0;
- }
- void print(const vector<vector<int> > &mat)
- {
- for (int i = 0; i < mat.size(); ++i)
- {
- cout << "{";
- for (int j = 0; j < mat[i].size(); ++j)
- {
- cout << mat[i][j];
- if (j != mat[i].size() - 1)
- cout << ",";
- }
- cout << "}" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement