You are viewing a single comment's thread. Return to all comments →
I just implemented without vector!
Please be careful about Memory Leaks!!!
#include <iostream> using namespace std; int main() { int n, q; cin >> n >> q; int** ptrArr = new int*[n]; // array of pointers! for (int i = 0; i < n; i++) { int k; cin >> k; // dynamic memory allocation! ptrArr[i] = new int[k]; for (int j = 0; j < k; j++) { cin >> ptrArr[i][j]; } } for (int x = 0; x < q; x++) { int i, j; cin >> i >> j; // access the target element! cout << ptrArr[i][j] << endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Variable Sized Arrays
You are viewing a single comment's thread. Return to all comments →
I just implemented without vector!
Please be careful about Memory Leaks!!!