返回题解分享
讨论 / 题解分享/ 帖子详情

算式求值 - 题解

#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long ans=0,temp,num;
    char ch;
    cin>>temp;
    while(cin>>ch>>num){
        if(ch=='+'){
            ans=(ans+temp)%10000;
            temp=num;
        }
        else temp=(temp*num)%10000;
    }
    ans=(ans+temp)%10000;
    cout<<ans;
}
0 回复 0 转发 1 喜欢 4 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!