2 条题解
-
0
Guest
-
0
#include<bits/stdc++.h> using namespace std; int main(){ stack<int> s; string a; cin>>a; int sum=0; for(int i=0;i<a.length();i++){ if(a[i]>='0'&&a[i]<='9'){ sum=sum*10+(a[i]-'0'); } else if(a[i]=='.'){ s.push(sum); sum=0; } else if(a[i]=='+'){ int a1=s.top(); s.pop(); int b1=s.top(); s.pop(); s.push(a1+b1); } else if(a[i]=='-'){ int a1=s.top(); s.pop(); int b1=s.top(); s.pop(); s.push(b1-a1); } else if(a[i]=='*'){ int a1=s.top(); s.pop(); int b1=s.top(); s.pop(); s.push(a1*b1); } else if(a[i]=='/'){ int a1=s.top(); s.pop(); int b1=s.top(); s.pop(); s.push(b1/a1); } if(a[i]=='@'){ break; } } cout<<s.top(); }
信息
- ID
- 273
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- 递交数
- 9
- 已通过
- 6
- 上传者