P1449 后缀表达式 栈的应用


栈的应用
当读到的数时入栈,当读到运算符时,对应数据出栈,计算后再入栈,当读到@时,栈顶为本题的解,这里的栈用C++stl的stack容器,简化代码的实现。

//P1449 后缀表达式
#include
#include
#include
using namespace std;
typedef long long LL;
stack  sd;
char bds[1001];
int main()
{
	cin>>bds;
	int bdslen=strlen(bds);
	int i=0;
	while (i='0'&&bds[i]<='9')
			{
				t=t*10+bds[i]-'0';
				i=i+1;
			}
			sd.push(t);
			i=i+1;
		}
	}
	cout<