题解
2023-12-26 22:08:23
发布于:浙江
11阅读
0回复
0点赞
#include <iostream>
#include<stack>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
char s;
long long a;
cin>>a;
stack<int> stk1;
a%=10000;
stk1.push(a);
long long sum = 0,b = 0;
while(cin>>s>>b){
if(s =='+'){
stk1.push(b);
}else if(s =='*'){
a = stk1.top();
stk1.pop();
stk1.push(a*b%10000);
}
}
int len = stk1.size();
for(int i=0;i<len;i++){
sum+=stk1.top();
sum%=10000;
stk1.pop();
}
cout<<sum<<endl;
}
这里空空如也
有帮助,赞一个