hiho week 169 register

Ended

Participants:408

Verdict:Accepted
Score:100 / 100
Submitted:2017-09-24 16:41:52

Lang:G++

Edit
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
#include <bits/stdc++.h>
using namespace std;
int apply(int op1, int op2, char op) {
    switch(op) {
        case '+': return op1 + op2;
        case '-': return op1 - op2;
        case '*': return op1 * op2;
        case '/': return op1 / op2;
    }
    return -1;
}
void gao() {
}
bool hasPrecedence(char op1, char op2) {
    if (op1 == '(') return false;
    if ((op1 == '+' || op1 == '-') && (op2 == '*' || op2 == '/')) return false;
    return true;
}
stack<int> nums;
stack<char> ops;
void reduce() {
    int op1 = nums.top(); nums.pop();
    int op2 = nums.top(); nums.pop();
    nums.push(apply(op2, op1, ops.top()));
    ops.pop();
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX