-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable-sized-arrays.cpp
More file actions
43 lines (31 loc) · 884 Bytes
/
variable-sized-arrays.cpp
File metadata and controls
43 lines (31 loc) · 884 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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
int main() {
std::vector<std::vector<int>> a;
std::string input;
std::getline(std::cin, input);
std::vector<int> arrayQueryLengths = {input[0] - '0', input[2] - '0'};
for (int i = 0 ; i < arrayQueryLengths[0]; i++)
{
std::vector<int> t;
std::getline(std::cin, input);
for (int j = 1; j < input.length(); j++)
{
if (!std::isspace(input[j]))
{
t.push_back(input[j] - '0');
}
}
a.push_back(t);
}
for (int i = 0; i < arrayQueryLengths[1]; i++)
{
std::getline(std::cin, input);
std::cout << a[input[0] - '0'][input[2] - '0'] << '\n';
}
return 0;
}