Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <set>
- #include <list>
- #include <cmath>
- #include <ctime>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <string>
- #include <bitset>
- #include <cstdio>
- #include <limits>
- #include <vector>
- #include <climits>
- #include <cstring>
- #include <cstdlib>
- #include <fstream>
- #include <numeric>
- #include <sstream>
- #include <iostream>
- #include <algorithm>
- #include <unordered_map>
- using namespace std;
- int main() {
- //Initialize & Declare Variables As Needed
- string input = " ";
- bool inputover = false;
- deque<char> str;
- deque<char> cmd;
- //Cycle until no more input
- while(!inputover)
- {
- //Get input
- getline(cin,input);
- //Prepare for next input
- cin.clear();
- //Check if end of input
- if(input.empty())
- {
- break;
- }
- //-----------------------------------------------------------
- //Start individual input code below here
- //-----------------------------------------------------------
- //Iterate though String
- while(input.length() > 0)
- {
- //Detect slash to indicate instruction
- if(input[0]=='/')
- {
- input.erase(input.begin());
- //Iterate through remaining string and split expression from Instruction
- while(input.length() > 0)
- {
- cmd.push_back(input[0]);
- input.erase(input.begin());
- }
- }
- else
- {
- str.push_back(input[0]);
- input.erase(input.begin());
- }
- }
- while(!cmd.empty())
- {
- if(cmd.front() == 'R')
- {
- stack<char> temp;
- while(!str.empty())
- {
- if(str.front() == '(')
- {
- temp.push(')');
- }
- else if(str.front() == ')')
- {
- temp.push('(');
- }
- else
- {
- temp.push(str.front());
- }
- str.pop_front();
- }
- while(!temp.empty())
- {
- str.push_back(temp.top());
- temp.pop();
- }
- }
- if(cmd.front() =='S')
- {
- if (str.[0]
- }
- cmd.pop_front();
- }
- //Display Expression
- //cout << "String" << endl;
- for (int i = 0; i < str.size(); i++)
- {
- cout << str[i];
- }
- cout << endl;
- /*
- //Display Instructions
- cout << "Command" << endl;
- for (int i = 0; i < cmd.size(); i++)
- {
- cout << cmd[i];
- }
- cout << endl;
- */
- str.clear();
- cmd.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement