Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
119519 | 陈家宝 | 表达式求值 | C++ | 通过 | 100 | 19 MS | 456 KB | 516 | 2024-01-08 13:03:53 |
#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; }