提交时间:2024-04-19 13:19:43
运行 ID: 143849
#include<bits/stdc++.h> using namespace std; stack<int> x;//一个存数字并在最后把它们相加的栈 int main(){ int a,b,m=10000; char c; cin>>a;//先输入一个数,以后符号+数字输入 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; }