Along_Dog @ 2022-06-27 19:52:16
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
stack<long long>a;
char c;
long long x=0;
int main(){
while(scanf("%c",&c)){
if(c=='@') break;
if(c>='0'&&c<='9'){
x=x*10+(c-48);
}
else if(c=='.'){
a.push(x-48);
//printf("%lld\n",x);
x=0;
}
else{
if(c=='+'){
long long x=a.top();
a.pop();
long long y=a.top();
a.pop();
a.push(x+y);
}
else if(c=='-'){
long long x=a.top();
a.pop();
long long y=a.top();
a.pop();
a.push(y-x);
}
else if(c=='*'){
long long x=a.top();
a.pop();
long long y=a.top();
a.pop();
a.push(x*y);
}
else if(c=='/'){
long long x=a.top();
a.pop();
long long y=a.top();
a.pop();
a.push(y/x);
}
}
}
printf("%lld\n",a.top());
return 0;
}
样例-176,就离谱
by SegTree @ 2022-06-27 19:56:28
else if(c=='.'){
a.push(x-48);
//printf("%lld\n",x);
x=0;
}
改为
else if(c=='.'){
a.push(x\);
//printf("%lld\n",x);
x=0;
}
@小黄牛njc
by SegTree @ 2022-06-27 19:57:04
多打了一个 \
qwq
by Along_Dog @ 2022-06-27 19:57:45
@jpb_Saturn 谢谢
by Along_Dog @ 2022-06-27 19:58:09
@lao_ba 通过阅读样例可以得知应该是y-x与y/x
by ajahjahah @ 2022-06-27 20:02:43
c我顺序看错了,抱歉了()