【委员】回应大风的要求:expression题解

Expression

题目

Description
Given a expression with only addition and multiplication, calculate the value.
Input
One line with the expression, with characters 0-9, ‘+’, and ‘*’. The number is 0~231-1
the number of ‘+’ character and ‘*’ character will <= 300
Output
One line, the value of the expression. If the length of the value is longer than 4, output the last 4. And do not output the leading zero.
Example Input
1+1*3+4
Example Output
8
Example Input
1+1234567890*1
Example Output
7891
Example Input
1+1000000003*1
Example Output
4

分析

题目就是一个计算器,只是我们输入的数字,全都模了10000而已。题目看起来很简单,但是还有两个需要注意的问题:

  1. 数字和运算符的抓取和存储
  2. 运算的优先级

大家可以先自己考虑一下,自己会怎么解决这两个问题。

代码

伟元的代码

总结

我就是被召唤来的苦力。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值