Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(){
- const int row = 5;
- const int col = 10;
- vector <int> vectorOne;
- vector <vector <int>> vectorTwo;
- // попытка сделать через итераторы
- vectorTwo.resize(row);
- for (vector<vector<int>>::iterator x = vectorTwo.begin(); x != vectorTwo.end(); ++x){
- (*x).resize(col);
- for (vector<int>::iterator y = vectorOne.begin(); y != vectorOne.end(); ++y){
- (*y).push_back(2);
- }
- vectorTwo.push_back(vectorOne);
- vectorOne.clear();
- }
- // через известные размерности
- vectorTwo.resize(row);
- for (decltype(vectorTwo.size()) x = 0; x != row; ++x){
- vectorTwo[x].resize(col);
- for (decltype(vectorTwo[x].size()) y = 0; y != col; ++y){
- vectorOne.push_back(x+y+2*x);
- cout << vectorOne[y] << " ";
- }
- cout << endl;
- vectorTwo.push_back(vectorOne);
- vectorOne.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement