include iostream include string include vector include stack using nam

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;
stack<char> kurwa_stack;
vector<string> kurwa_symbols_stack;
char kurwa[13][13] = {
{' ', 'Z', 'E', 'R', 'T', 'D', 'F', 'i', '(', ')', '+', '*', '#'},
{'Z', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '=', ' ', ' ', '='},
{'R', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', '=', ' ', '>'},
{'T', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', '>', ' ', '>'},
{'D', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', '>', '=', '>'},
{'F', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', '>', '>', '>'},
{'i', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', '>', '>', '>'},
{'(', ' ', '=', '<', '<', '<', '<', '<', '<', ' ', ' ', ' ', ' '},
{')', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', '>', '>', '>'},
{'+', ' ', ' ', ' ', '=', '<', '<', '<', '<', ' ', ' ', ' ', ' '},
{'*', ' ', ' ', ' ', ' ', ' ', '=', '<', '<', ' ', ' ', ' ', ' '},
{'#', ' ', '=', '<', '<', '<', '<', '<', '<', ' ', ' ', ' ', ' '}
};
int get_index_by_row(char symbol) {
for (int i = 1; i < 13; i++)
if (kurwa[0][i] == symbol)
return i;
return 7;
}
int get_index_by_column(char symbol) {
for (int i = 1; i < 13; i++)
if (kurwa[i][0] == symbol)
return i;
return 7;
}
char search_relationship(char symbol1, char symbol2) {
int i = get_index_by_row(symbol1);
int j = get_index_by_column(symbol2);
return kurwa[i][j];
}
string get_expression(string str, int index) {
string result = "";
//char last_ch = kurwa_stack.si
while (str[index] != '<') {
result += str[index--];
}
return result;
}
string parse_relationship(string str) {
string result = "";
for (int i = 1; i < str.length(); i++) {
char last_ch = search_relationship(str[i - 1], str[i]);
//kurwa_stack.push_back(last_ch);
if (last_ch == '>')
kurwa_symbols_stack.push_back(get_expression(str, i));
}
return result;
}
int main(int argc, const char * argv[]) {
char a, b;
cin >> a >> b;
kurwa_stack.push(a);
kurwa_stack.push(b);
cout << kurwa_stack.top();
/*string str;
cout << "Enter new expression" << endl;
cin >> str;
cout << "Your result is " << parse_relationship(str) << endl;
*/
return 0;
}