-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathccc08j4.cpp
39 lines (35 loc) · 853 Bytes
/
ccc08j4.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
#include <bits/stdc++.h>
using namespace std;
vector<string> split(string &a, char c)
{
vector<string> ret;
string cur;
for (auto &x : a)
{
if (x == c)
ret.push_back(cur), cur = "";
else
cur += x;
}
if (cur != "")
ret.push_back(cur);
return ret;
}
int main()
{
string in;
for (getline(cin, in); in != "0"; getline(cin, in))
{
vector<string> tokens = split(in, ' ');
for (int y = tokens.size()-1; y >= 0; y--)
{
if (tokens[y] == "+" || tokens[y] == "-")
{
tokens[y] = tokens[y+1] + " " + tokens[y+2] + " " + tokens[y];
tokens.erase(tokens.begin()+y+2);
tokens.erase(tokens.begin()+y+1);
}
}
cout<<tokens[0]<<"\n";
}
}