编程介的小学生 2019-09-15 21:40 采纳率: 20.5%
浏览 93

Gary's Calculator 计算器编程

Problem Description
Gary has finally decided to find a calculator to avoid making simple calculational mistakes in his math exam. Unable to find a suitable calculator in the market with enough precision, Gary has designed a high-precision calculator himself. Can you help him to write the necessary program that will make his design possible?
For simplicity, you only need to consider two kinds of calculations in your program: addition and multiplication. It is guaranteed that all input numbers to the calculator are non-negative and without leading zeroes.

Input
There are multiple test cases in the input file. Each test case starts with one positive integer N (N < 20), followed by a line containing N strings, describing the expression which Gary's calculator should evaluate. Each of the N strings might be a string representing a non-negative integer, a "*", or a "+". No integer in the input will exceed 109.
Input ends with End-of-File.

Output
For each test case, please output one single integer (with no leading zeros), the answer to Gary's expression. If Gary's expression is invalid, output "Invalid Expression!" instead. Please use the format indicated in the sample output.

Sample Input
3
100 + 600
3
20 * 4
2

  • 500 5 20 + 300 * 20

Sample Output
Case 1: 700
Case 2: 80
Case 3: Invalid Expression!
Case 4: 6020

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常
    • ¥15 关于风控系统,如何去选择
    • ¥15 这款软件是什么?需要能满足我的需求
    • ¥15 SpringSecurityOauth2登陆前后request不一致
    • ¥15 禅道二次开发编辑版本,上传不了发行包