zhangshibo678 @ 2022-07-19 08:18:13
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
stack <int> ch;
int main(){
int i=0;
string s;
getline(cin,s);
while(s[i]!='@')
{
if(s[i]!='.'&&s[i]!='+'&&s[i]!='-'&&s[i]!='*'&&s[i]!='/'){
ch.push (s[i]);
}
int x=ch.top(); ch.pop();
int y=ch.top(); ch.pop();
switch(s[i]){
case '+':ch.push(x+y);break;
case '-':ch.push(y-x);break;
case '*':ch.push(x*y);break;
case '/':ch.push(y/x);break;
}
}
i++;
int w=ch.top();
cout<<w;
return 0;
}
by Code_AC @ 2022-07-19 08:22:07
@zhangshibo521 您往一个int类型的栈里放字符?
by NetherDevil @ 2022-07-19 08:29:23
@zhangshibo521 提示:ch.push('0')
会把 48 放入你的栈中。
by StarLbright40 @ 2022-07-19 08:38:55
你搁哪 i++;
呢