-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_exptrans.cpp
More file actions
41 lines (38 loc) · 838 Bytes
/
4_exptrans.cpp
File metadata and controls
41 lines (38 loc) · 838 Bytes
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
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
int N,i,l=0;
//vector<char> in,out;
string in,out;
vector<char> temp;
cin>>N;
while(N--)
{
cin>>in;
out.clear();
for(i=0;i<in.size();i++)
{
if(in[i]==')')
{
while(temp[l-1]!='(')
{
out += temp[l-1] ;
l--;temp.pop_back();
}
l--;temp.pop_back();
}
else if((in[i]=='(')||(in[i]=='+')||(in[i]=='-')||(in[i]=='*')||(in[i]=='/')||(in[i]=='^'))
{
temp.push_back(in[i]);
l++;
}
else
out+=in[i];
}
cout<<out<<"\n";
}
return 0;
}