Huawei OD test questions-Excel cell numerical statistics [2023Q2] [JAVA, Python, C++]

Title description: The function of counting the values ​​​​of the selected area in the Excel worksheet is very practical.
Following this function of Excel, please perform sum statistics on the cells in the selected area in the given table, and output the statistical results.

To simplify the calculation, it is assumed that the content of each cell in the current input is only numbers or formulas.

  • If it is a number, it is a non-negative integer, such as 3, 77
  • If it is a formula, it must start with = and only include the following three situations:
  1. Equal to the value of a certain cell, for example =B12
  2. Binocular operation of two cells (only + or -), in the form of =C1-C2, C3+B2
  3. Binocular operation of cells and numbers (only + or -), in the form of =B1+1, 100-B2

Note :

  • The content of the formula is legal, for example, if it does not exist, =C+1, =C1-C2+B3, =5, =3+5
  • There are no circular references, such as A1=B1+C1, C1=A1+B2
  • There are no spaces or brackets in the content

Input description: two integers rows cols in the first row, indicating the number of rows and columns in a given table area, 1<=rows<=20, 1<=cols<=26.
Next rows are rows of cols space-separated strings representing the cell contents of the given table values.

The character string entered in the last line represents the given selected area, in the form of A1:C2.

Output description:

An integer representing the accumulation of numbers in each cell of the given selection

Guess you like

Origin blog.csdn.net/2301_76848549/article/details/130162951