萌新求助站外题awa
#include<bits/stdc++.h>
using namespace std;
stack<long long>stk;
char s;
int a,b,ans;
int main()
{
while(s=getchar(),s!='@')
{
if(s>='0'&&s<='9')
{
stk.push(s-'0');
}
else if(s=='+')
{
a=stk.top();
stk.pop() ;
b=stk.top();
stk.pop();
stk.push(a+b);
}
else if(s=='-')
{
b=stk.top();
stk.pop() ;
a=stk.top();
stk.pop();
stk.push(a-b);
}
else if(s=='*')
{
a=stk.top();
stk.pop() ;
b=stk.top();
stk.pop();
stk.push(a*b);
}
else if(s=='/')
{
a=stk.top();
stk.pop() ;
b=stk.top();
stk.pop();
stk.push(a/b);
}
}
cout<<stk.top();
return 0;
}
初学栈,好无语。。。。。。 全WA!!!