-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable-sized-arrays.cpp
More file actions
45 lines (36 loc) · 973 Bytes
/
Copy pathvariable-sized-arrays.cpp
File metadata and controls
45 lines (36 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int noOfTables;
int noOfQuerries;
int** tables = nullptr;
cin >> noOfTables >> noOfQuerries;
tables = new int* [noOfTables];
for(int i = 0; i < noOfTables; i++)
{
int size;
cin >> size;
tables[i] = new int[size];
for(int j = 0; j < size; j++)
{
cin >> tables[i][j];
}
}
int* tableOfQuarries = new int[noOfQuerries*2];
for(int i = 0; i < noOfQuerries; i++)
{
cin >> tableOfQuarries[i*2] >> tableOfQuarries[(i*2)+1];
}
for(int i = 0; i < noOfQuerries; i++)
{
cout <<tables[tableOfQuarries[i*2]][tableOfQuarries[(i*2)+1]] << endl;
}
delete [] tableOfQuarries;
for(int i = 0; i < noOfTables; i++) delete [] tables[noOfTables];
delete [] tables;
return 0;
}