Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
920 B
1
Indexable
Never
#include <iostream>
using namespace std;
int main() {
    string a;
    cin >> a;
    int h;
    for (int i = 0; i < a.size(); i++){
        if (a[i] == 'x') {
            h = i;
            break;
        }
    }
    if (h == 0) {
        int j = int(a[4]) - 48;
        int h = int(a[2]) - 48;
        if (a[1] == '-') {
            cout << j + h;
        }
        else if (a[1] == '+') {
            cout << j - h;
        }
    }
    if (h == 2) {
        int j = int(a[4]) - 48;
        int h = int(a[0]) - 48;
        if (a[1] == '-') {
            cout << h - j;
        }
        else if (a[1] == '+') {
            cout << j - h;
        }
    }
    if (h == 4) {
        int j = int(a[0]) - 48;
        int h = int(a[2]) - 48;
        if (a[1] == '+') {
            cout << j + h;
        }
        else if (a[1] == '-') {
            cout << j - h;
        }
    }
}