编程介的小学生 2017-02-21 14:02 采纳率: 20.5%
浏览 941
已采纳

Spreadsheet

Description

You are to write a program emulating a very simple spreadsheet application. It works with a table with 9 rows, from "1" to "9", and 26 columns, from "A" to "Z". Table cells are referenced by names composed of column and row codes, ex. "B1", "S8".

Each cell contains an expression up to 255 characters long. Expressions use integer constants, cell references, parenthesis, operators "+", "-", "*", and "/" (whole division). For example: 567, E8/2, (3+B3)*(C4-1) are all valid expressions. All operators are whole, all arguments and results are guaranteed to be less than 1000000. Division by zero yields zero.

If the value of the cell referenced by some expression is not defined, it is presumed to be 0 (zero). The situation when two or more cells are mutually dependent on each other is considered a special case of "circular reference".
Input

First input line contains number of expressions N. Following N lines are in format < Cell reference>=< expression>. All expressions are correct, and each cell is defined by at most one expression.
Output

Output file must contain single line with either the value of the cell "A1" or number 1000000 (one million) if the value of A1 cannot be computed due to a circular reference.
Sample Input

4
A1=B1+C5
B1=20
C5 =B1 /D7-E1*E1
E1=(3+1)*2
Sample Output

-44

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-02-28 14:35
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog