/home/toolbox/public_html/solutions/119/11988/a1.cpp
1 #include <cstdio>
2 #include <cstring>
3 #include <list>
4
5 using namespace std;
6
7 #define TRUE (1 == 1)
8 #define FALSE (1 != 1)
9
10 #define DEBUG if (FALSE)
11
12 #define MAX_LINE 100005
13
14 /*
15 * Author: Isaac Traxler
16 * Date:
17 * Purpose: fun
18 * Problem:
19 */
20
21 /*
22 * This template reads lines of data at a time until end of file.
23 */
24
25 char line[MAX_LINE];
26 list<char> outline;
27 list<char>::iterator it;
28
29 void init()
30 {
31 /* FUNCTION init */
32 } /* FUNCTION init */
33
34 void dump()
35 {
36 /* FUNCTION dump */
37 } /* FUNCTION dump */
38
39 int getInput()
40 {
41 /* FUNCTION getInput */
42 int dataReadFlag;
43
44 dataReadFlag = EOF != scanf("%s", line);
45 return (dataReadFlag);
46 } /* FUNCTION getInput */
47
48 void process()
49 {
50 /* FUNCTION process */
51 int i;
52 int tmp;
53
54 outline.clear();
55 it = outline.begin();
56 tmp = strlen(line);
57 for (i=0; i<tmp; i++)
58 {
59 /* for each char */
60 switch (line[i])
61 {
62 /* switch */
63 case '[':
64 it = outline.begin();
65 break;
66 case ']':
67 it = outline.end();
68 break;
69 default:
70 outline.insert(it, line[i]);
71 } /* switch */
72 } /* for each char */
73 for (it=outline.begin(); it != outline.end(); it++)
74 {
75 /* dump result */
76 printf("%c", *it);
77 } /* dump result */
78 printf("\n");
79 } /* FUNCTION process */
80
81 int main()
82 {
83 /* main */
84 int moreToDo;
85
86 init();
87 moreToDo = getInput();
88 while (moreToDo)
89 {
90 /* while */
91 process();
92 moreToDo = getInput();
93 } /* while */
94
95 return 0;
96 } /* main */
97