Module: Dynamic arrays: vector


Problem

6 /8


Array queries

Problem

You need to implement an array-based data structure that can respond to these types of requests:

0 - print array size and newline sign;
1 x - add the number x to the end of the array;
2 - remove the last element of the array;
3 x y - insert number y between array elements x and x + 1;
4 x - remove element №x;
5 - display all elements of the array in the order they appear in it, separated by a space. At the end, output a newline sign;
6 x - change array size to x. If x is less than the current size of the array, then all elements starting from element №x are discarded. If x is greater than the current size of the array, then the resulting array elements will be equal to 0.
 
Input: 
- the first line contains the number N (\(1 <= n <= 100\));
- the next N lines contain requests in the format written in the condition.
 
Output: Print responses to queries like 0 and 5.
 
Examples
# Input Output
1
9
0
1 5
2
0
10
1 3
2
1 1
5
0
0
0 1