#include <iostream>
#include <string>
using namespace std;
class solution
{
public:
int calculate(string s)
{
int result = 0, inter_res = 0, num = 0;
char op = '+';
char ch;
//找到第一个不为空的字符
for (int pos = s.find_first_not_of(' '); pos < s.size(); pos = s.find_first_not_of(' ', pos))
{
ch = s[pos];
//判断是否是数字
if (ch >= '0' && ch <= '9')
{
int num = ch - '0';
//判断下一个字符是否也是数字
while (++pos < s.size() && s[pos] >= '0' && s[pos] <= '9')
num = num * 10 + s[pos] - '0';
switch (op)
{
case '+':
inter_res += num;
break;
case'-':
inter_res -= num;
break;
case'*':
inter_res *= num;