sd_JC @ 2023-10-22 13:41:01
https://www.luogu.com.cn/record/130993845
#include <bits/stdc++.h>
using namespace std;
stack<int>n;
char c;
int s=0,x,y;
int main(){
while(c!='@'){
c=getchar();
if(c=='@')break;
else if('0'<=c&&c<='9')
s=s*10+c-'0';
else if(c=='.'){
n.push(s);s=0;
}
else{
x=n.top(); n.pop();
y=n.top(); n.pop();
if(c=='+')n.push(x+y);
if(c=='-')n.push(y-x);
if(c=='*')n.push(x*y);
if(c=='/')n.push(x/y);
}
}
cout<<n.top();
return 0;
}
by xiaozhangawa @ 2023-10-29 11:04:05
除法写错了,应该是y/x