uva 727 运算符 中缀到后缀的转换
来源:互联网 发布:java如何设置全局变量 编辑:程序博客网 时间:2024/06/02 06:06
卡了好久好久 一直没敢在动 今天一遍AC
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <stack>
using namespace std;
stack<char>operat;
int main()
{
//freopen("in.in","r",stdin);
int test_case;
cin>>test_case;
cin.ignore(1);
char c;
int flage = 0;
while(test_case--)
{
while((c = getchar()) != EOF)
{
if(c == '/n')
{
flage++;
if(flage == 2) break;
continue;
}
flage = 0;
if(isdigit(c))
cout<<c;
else{
if(c == '+' || c == '-'){
while(!operat.empty())
{
if(operat.top() != '(' )
{
cout<<operat.top();
operat.pop();
}
else break;
}
operat.push(c);
}
else if(c == '*' || c == '/')
{
while(!operat.empty())
{
if(operat.top() == '*' || operat.top() == '/')
{
cout<<operat.top();
operat.pop();
}
else break;
}
operat.push(c);
}
else if(c == '(')
operat.push(c);
else if(c == ')')
{
while(!operat.empty())
{
if(operat.top() != '(')
{
cout<<operat.top();
operat.pop();
}
else
{
operat.pop();
break;
}
}
}
}
}
while(!operat.empty())
{
cout<<operat.top();
operat.pop();
}
if(test_case != 0) cout<<endl;
cout<<endl;
}
return 0;
}
- uva 727 运算符 中缀到后缀的转换
- 中缀到后缀的转换
- 中缀到后缀的转换
- 中缀到后缀表达式的转换
- 中缀表达式到后缀表达式的转换
- 中缀表达式到后缀表达式的转换
- 数据结构-----中缀到后缀的转换
- 中缀表达式到后缀表达式的转换
- 栈的应用:后缀表达式到中缀表达式的转换
- 实现中缀表达式到后缀表达式的转换
- 中缀表达式到后缀表达式的转换C++实现
- 二叉树中缀表达式到后缀表达式的转换
- 中缀到后缀表达式的转换:java-stack实现
- Java实现:利用栈实现中缀到后缀的转换
- 中缀后缀表达式的转换
- 栈的应用 平衡符号 后缀表达式 中缀到后缀的转换
- C++栈的应用——后缀表达式求值、中缀表达式到后缀表达式的转换
- 后缀表达式(4)-——中缀表达式到后缀表达式的转换,递归实现
- java线程同步之死锁问题
- 要特别注意写代码之前的设计
- 使用synergy!
- 大端法、小端法、网络字节序
- 怎样解决数据库 Navicat 8for MySQL中不能连接到本地数据库的问题啊??请大虾们帮忙
- uva 727 运算符 中缀到后缀的转换
- jdbc操作测试类
- 华为的一道C语言面试题
- java上此类开发包非常多,想问问各位C++同仁知道什么比较好的开发包for C/C++的吗
- BREW/BREWMP手机硬件参数差异性浅析
- virtual 关键字
- windows7 下亮度条调屏幕背光
- WCF+Nhibernate 序列化的问题
- 网络世界里的攻防战