SDUT OJ 数据结构实验之栈二:一般算术表达式转换成后缀式

2015-01-26 23:15:57 · 作者: · 浏览: 4

\

#include
  
   
using namespace std;
int youxian(char s)
{
	if(s=='+'||s=='-') return 1;
	else if(s=='*'||s=='/') return 2;
	else if(s=='(')  return 3;
	else if(s==')')  return 4;
}
int main()
{
	int top=0;
	char s,b[110];
	while(cin>>s && s!='#')
	{
		if(s>='a' && s<='z')
			cout<
   
youxian(b[top-1])) { if(youxian(s)==4) { while(b[top-1]!='(') { cout<