#include #include using namespace std; int getValue(string input, int* offset) { int x = 0; int flag1 = 1; int index = *offset; if (input[index] == '+') { flag1 = 1; ++index; } else if (input[index] == '-') { flag1 = -1; ++index; } for (int i = 0; i < input.length(); ++i) { if (input[index] < '0' || input[index] > '9') { break; } x *= 10; x += input[index] - '0'; ++index; } x *= flag1; *offset = index; return x; } int main() { string input = ""; cin >> input; int offset = 0; int x = getValue(input, &offset); char op = input[offset]; ++offset; int y = getValue(input, &offset); if (op == '+') { cout << x - y << endl; } else { cout << x + y << endl; } getchar(); getchar(); }