提交时间:2024-01-08 13:03:53
运行 ID: 119519
#include<bits/stdc++.h> using namespace std; stack<int> x;//一个存数字并在最后把它们相加的栈 int main() { int a,b; char c; cin>>a;//先输入一个数,以后符号+数字输入 int m=10000; a=a%m; x.push(a);//压入栈中 while(cin>>c>>b){ if(c=='*'){//将*之前的数字与*之后的数字积存入 a=x.top(); x.pop(); x.push(a*b%m); } else x.push(b);//将b存入 } a=0; while(x.size()){ a+=x.top(); a%=m; x.pop(); } cout<<a; return 0; }