You are viewing a single comment's thread. Return to all comments →
Here is my code!
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int num_arrays, num_queries, num_items, current_item, array_i, item_i; vector<int> current_array; scanf("%d %d", &num_arrays, &num_queries); vector<vector<int>> arrays; for (int i = 0; i < num_arrays; i++) { current_array = {}; scanf("%d", &num_items); for (int item = 0; item < num_items; item++) { scanf("%d", ¤t_item); current_array.push_back(current_item); } arrays.push_back(current_array); } for (int i = 0; i < num_queries; i++) { scanf("%d %d", &array_i, &item_i); printf("%d", arrays[array_i][item_i]); if (i != num_queries - 1) { printf("\n"); } } 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 →
Here is my code!