-
Notifications
You must be signed in to change notification settings - Fork 0
/
brtsgnONP.cpp
48 lines (45 loc) · 935 Bytes
/
brtsgnONP.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main()
{
vector <char> charVector;
stack <char> charStack;
char char1,char2;
int charCount=0;
int count=0;
cin>>count;
int x;
while (count--)
{
charVector.clear();
x=0;
cin>>char1;
x++;
while (x != 0) {
cin>>char2;
if (char2=='(') {
x++;
}
else {
if (char2==')') {
x--;
charVector.push_back(charStack.top());charStack.pop();
}else {
if (char2=='+' || char2=='-' || char2=='*' || char2=='/' || char2=='^' /*|| char2=='%' || char2=='_' || char2=='|' || char2==';' || char2=='?'|| char2=='~'*/) {
charStack.push(char2);
}else {
charCount++;
charVector.push_back(char2);
}
}
}
}
for (int i=0; i<charVector.size(); i++) {
cout<<charVector.at(i);
}
cout<<endl;
}
return 0;
}