// jagged array demonstration // Mikhail Nesterenko // 11/29/2016 #include #include using std::cin; using std::cout; using std::endl; using std::vector; int main (){ vector row; vector> a; // populating table with continously increasing rows for(int i=0; i < 4; ++i) { row.push_back(i); a.push_back(row); } // printing the table for (int i=0; i < a.size(); ++i){ for (int j=0; j < a[i].size(); ++j) cout << a[i][j] << " "; cout << endl; } cout << endl; // removing middle row a.erase(a.begin()+1); // adding element to a middle row a[2].insert(a[2].begin()+1, 55); // printing resulting table for (int i=0; i < a.size(); ++i){ for (int j=0; j < a[i].size(); ++j) cout << a[i][j] << " "; cout << endl; } }