Time Limit: 3000ms, Memory Limit: 10000KB , Accepted: 277, Total Submissions: 763
Description
假设表达式由单字母变量和双目四则运算算符构成。试编写程序,将一个通常书写形式且书写正确的表达式转换为逆波兰式。
Input
输入由单字母变量和双目四则运算算符构成的表达式。
Output
输出其逆波兰式。
样例输入:
(a+b)*c
样例输出:
ab+c*
#include <iostream>
#include <stack>
#include <string>
using namespace std;
bool judge(char x,char y){
if(x=='*'&&(y=='+'||y=='-'))
return true;
else if(x=='/'&&(y=='+'||y=='-'))
return true;
else
return false;
}
int main()
{
string str;
stack<char> s;
cin>>str;
int i;
char t;
int len=str.length();
for(i=0;i<len;i++){
if(str[i]>=&#