We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Introduction
- Variable Sized Arrays
- Discussions
Variable Sized Arrays
Variable Sized Arrays
Sort by
recency
|
1432 Discussions
|
Please Login in order to post a comment
int main() {
}
For anyone with doubts about the problem I will try to explain it (then I will attach a video to youtube if it's not enough).
So it ask us for a 2 dimensional array, twice, in other words you will need to declare one 2d array and call it twice, "a" means how many arrays will be in the 2d array, and "q" is basically asking "Hey I will ask (q) number of times about the array, different question each time".
The first line of input (2 2) means ; it will be a 2d array that contains “2” different arrays, and the other “2” means how many questions it's going to ask.
The next line of inputs (3 1 5 4) and (5 1 2 8 9 3) is a bit more complicated. In the first line (3 1 5 4) Means two things, the first number (3 …) means how large will the array be, meaning that the next numbers are going to be the content of the array (... 1 5 4), in other words “3” is the size of the array, “1 5 4” is what is inside. It's the same with the second line, (5 1 2 8 9 3), “5” is the size of the array, and “... 1 2 8 9 3” is the content.
For the last two lines of input (0 1) and (1 3) are coordinates, basically, in c++ a 2d array looks like “ int array [x] [y] “, the input (0 1) replaces “x” and “y” inside the array, so, the query is “ int array [0] [1] “, and in programming, the computer counts starting at 0, so “0” directs you to the 1st array of the 2d array (1 5 4), and “1” is the 2nd value of that array, so “ int array [0] [1] “ outputs “5”, the 2nd number of the 1st array. For the last two lines of input (0 1) and (1 3) are coordinates, basically, in c++ a 2d array looks like “ int array [x] [y] “, the input (0 1) replaces “x” and “y” inside the array, so, the query is “ int array [0] [1] “, and in programming, the computer counts starting at 0, so “0” directs you to the 1st array of the 2d array (1 5 4), and “1” is the 2nd value of that array, so “ int array [0] [1] “ outputs “5”, the 2nd number of the 1st array.
Input (1 3) means “ array [1] [3] “, it outputs the 4th (3) number of the 2nd (1) array; if you are asking ‘What happened to the 3 and the 5 in the second and third line of input’ those just say how big the mentioned subsidiary array is.
The youtube video: https://www.youtube.com/watch?v=IMsDWK0twOY
i dont understand the problem, even i spend a lot of time but didnt understand the problem
My C++ code without vector
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n, q , k , l , pl , pt; cin >> n >> q ; vector> num(n);
}