这道题是不是能用树的后序遍历做(dfs),还有你的RE是什么意思
by xxxst @ 2023-08-25 21:51:13
为什么你要用double???
by Mark_Zhu @ 2023-08-30 20:55:44
```c
#include<bits/stdc++.h>
using namespace std;
stack<int>s;
int main(){
char c;
while(cin>>c){
if(c=='@'){
cout<<s.top();
return 0;
}
if(c>='0' and c<='9'){
int x=0;
while(c!='.'){
x=x*10+c-'0';
cin>>c;
}
s.push(x);
}
if(c=='+'){
int a=s.top();
s.pop();
int b=s.top();
s.pop();
s.push(a+b);
}
if(c=='-'){
int a=s.top();
s.pop();
int b=s.top();
s.pop();
s.push(b-a);
}
if(c=='/'){
int a=s.top();
s.pop();
int b=s.top();
s.pop();
s.push(b/a);
}
if(c=='*'){
int a=s.top();
s.pop();
int b=s.top();
s.pop();
s.push(a*b);
}
}
cout<<s.top();
return 0;
}
```
by Mark_Zhu @ 2023-08-30 21:21:17
他的/是整除(我试过,还花费了一次下载数据),这是我的代码,希望有用。
by Mark_Zhu @ 2023-08-30 21:24:35
作为答谢,能关注一下我吗(非硬性要求)?我也关注你。
by Mark_Zhu @ 2023-08-30 21:28:03