Created
October 23, 2015 06:18
-
-
Save xunkai55/1e36a0160ad568498d20 to your computer and use it in GitHub Desktop.
move a vector from a vector2D to another one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <utility> | |
using namespace std; | |
void PrintVec2D(vector<vector<int>> &d) { | |
for (int i = 0; i < d.size(); i++) { | |
cout << "subvec " << i << ": "; | |
for (int j = 0; j < d[i].size(); j++) | |
cout << d[i][j] << " "; | |
cout << endl; | |
} | |
} | |
int main() { | |
vector<vector<int>> t; | |
vector<vector<int>> d; | |
t.resize(5); | |
d.resize(1); | |
for (int i = 0; i < 5; i++) { | |
for (int j = 0; j < 3; j++) | |
t[i].push_back(i + j); | |
} | |
for (auto &f: t) { | |
cout << "src" << endl; | |
PrintVec2D(t); | |
d[0] = move(f); | |
cout << "des" << endl; | |
PrintVec2D(d); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment