题解
2023-07-07 20:48:58
发布于:江苏
12阅读
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;
}
这里空空如也
有帮助,赞一个