You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
char a[1010101];//KAO,第一次下手不够狠,居然RE了两个点!!
|
|
|
|
|
queue<string> q1;
|
|
|
|
|
queue<char> q2;
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
scanf("%s", a);
|
|
|
|
|
string s1 = "", s2 = "";
|
|
|
|
|
|
|
|
|
|
for (int i = 0; a[i] != '\0';) {
|
|
|
|
|
//数字
|
|
|
|
|
while (a[i] >= '0' && a[i] <= '9') {
|
|
|
|
|
s1 += a[i];
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
if (s1.size() > 0) {
|
|
|
|
|
q1.push(s1);
|
|
|
|
|
s1.clear();
|
|
|
|
|
}
|
|
|
|
|
//操作符
|
|
|
|
|
if (a[i] == '+' || a[i] == '-') {
|
|
|
|
|
q2.push(a[i]);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
long result;
|
|
|
|
|
//字符串转数字长整型
|
|
|
|
|
istringstream(q1.front()) >> result;
|
|
|
|
|
q1.pop();
|
|
|
|
|
|
|
|
|
|
while (!q1.empty()) {
|
|
|
|
|
long second;
|
|
|
|
|
istringstream(q1.front()) >> second;
|
|
|
|
|
q1.pop();
|
|
|
|
|
char c = q2.front();
|
|
|
|
|
q2.pop();
|
|
|
|
|
|
|
|
|
|
if (c == '+') {
|
|
|
|
|
result += second;
|
|
|
|
|
} else {
|
|
|
|
|
result -= second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cout << result << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|