Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ff(i, n) for (int i = 0, END = (n); i < END; i ++)
#define fff(i, n, m) for (int i = (n), END = (m); i <= END; i ++)
#define dff(i, n, m) for (int i = (n), END = (m); i >= END; i --)
#define travel(e, first) for (int e = first, v = vv[first]; ~e; e = nxt[e], v = vv[e])
#define clr(a, b) memset(a, b, sizeof(a))
typedef long long ll;
int main() {
string in;
while (cin >> in) {
ll now = 0;
char op = '+';
for (char ch: in) {
if (isdigit(ch)) {
int num = ch - '0';
if (op == '+') { now += num; }
if (op == '-') { now -= num; }
if (op == '*') { now *= num; }
} else {
op = ch;
}
}
cout << now << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.