Huawei OD computer test-two-dimensional array operation (C++ & Java & JS & Python)

describe

There is a data table of size �∗� m∗n. You will perform the following 5 operations in sequence:

1. Input � m and � n and initialize a table of size �∗� m∗n.

2. Enter �1x1​, �1y1​, �2x2​, �2y2​, and exchange the coordinates between (�1,�1)(x1​,y1​) and (�2,�2)(x2​,y2​ ) of two numbers.

3. Enter � x to add a line above line � x.

4. Enter � y to add a column to the left of the � y-th column.

5. Enter � x , � y to find the value of the cell with coordinates (�,�) (x,y).

Please write a program to determine whether various operations on the table are legal.

Detailed requirements:

1. The maximum specification of the data table is 9 rows * 9 columns. When operating the table, an error will be returned if the specification exceeds the specification.

2. For insertion operations, if the number of rows or columns exceeds 9 after insertion, an error should be returned. If the insertion is successful, the data table will be restored to the initial size of �∗� m∗n, and the excess data should be discarded.

3. For all input coordinate operations, for tables of size �∗� m∗n, the row number coordinates only allow 0~m-1, and the column number coordinates only allow 0~n-1. Out of range should return an error.

This question contains multiple sets of sample inputs! Rows and columns are numbered starting from 0

Data range: Number of data groups: 1≤�≤5 1≤t≤5 

Advanced: Time complexity: �(1) O(1), Space complexity: �(1) O(1) 

Enter description:

Guess you like

Origin blog.csdn.net/m0_68036862/article/details/132873669