-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhau_to_tien_to.cpp
More file actions
44 lines (44 loc) · 846 Bytes
/
hau_to_tien_to.cpp
File metadata and controls
44 lines (44 loc) · 846 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
42
43
44
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <string>
using namespace std;
long long mod = 1e9 + 7;
void slove()
{
string s;
cin >> s;
stack<string> a;
int len = s.size();
for (int i = 0; i < len; i++)
{
if (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/')
{
string x = a.top();
a.pop();
string y = a.top();
a.pop();
string tmp = s[i] + y + x;
a.push(tmp);
}
else
a.push(string(1, s[i]));
}
cout << a.top() << "\n";
}
int main()
{
int t = 1;
cin >> t;
cin.ignore();
while (t--)
{
slove();
}
return 0;
}