编程介的小学生 2017-08-14 08:19 采纳率: 20.5%
浏览 694
已采纳

SHEET

Description

See if a spreadsheet has a consistent formulation.
Any given cell of a spreadsheet can have a formula that depends on the value from some other cell. Before trying to calculate the value of a cell it is important to determine if the definition of the formula for that cell is circular.

Our spreadsheet only has a limited formulation for expressions:
definition := cell "=" expression

expression := term | expression "+" term | expression "-" term

term := factor | term "*" factor | term "/" factor

factor := number | cell | "(" expression ")"

number := digit | number digit

digit := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

cell := "R" digit digit "C" digit digit

Valid cell rows and columns are 1 through 20, so that a total of 400 cells are available in our spreadsheet.
Input

The input will contain one or more lines, each representing cells that are defined in the spreadsheet.
Note that, if an expression in some cell refers to some other cell, the contents of that other cell will always be defined.There are no white space characters in the expressions.
Output

A single line is printed for each cell defined in the input(and in the same order). This should be the cell name followed by "circular" if evaluating the cell results in a circular definition (either directly or indirectly). If the cell can be evaluated without a circular definition, then the word "ok" should follow the cell.
Sample Input

R01C01=1
R01C02=2
R01C03=R01C01+R01C02
R02C01=(R03C02+1)*R01C03
R03C02=R02C01
Sample Output

R01C01 ok
R01C02 ok
R01C03 ok
R02C01 circular
R03C02 circular

  • 写回答

1条回答 默认 最新

  • devmiao 2017-08-27 15:49
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面