Go: package main

import (
	"bufio"
	"fmt"
	"go/token"
	"go/types"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	for i := 0; i < n; i++ {
		stdin.Scan()
		exp := strings.TrimRight(stdin.Text(), "=")
		res, _ := types.Eval(token.NewFileSet(), nil, token.NoPos, exp)
		fmt.Println(res.Value)
	}
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
using State = string::iterator;

class Solve {
public:
    void input() {

    }

    int expression(State &begin) {
        int ret = term(begin);

        while (true) {
            if (*begin == '+') {
                begin++;
                ret += term(begin);
            } else if (*begin == '-') {
                begin++;
                ret -= term(begin);
            } else if (*begin == ' ') {
                begin++;
            } else {
                break;
            }
        }
        return ret;
    }

    int term(State &begin) {
        int ret = factor(begin);
        while (true) {
            if (*begin == '*') {
                begin++;
                ret *= factor(begin);
            } else if (*begin == '/') {
                begin++;
                ret /= factor(begin);
            } else if (*begin == ' ') {
                begin++;
            } else {
                break;
            }
        }
        return ret;
    }

    int factor(State &begin) {
        if (*begin == '(') {
            begin++;
            int ret = expression(begin);
            begin++;
            return ret;
        } else {
            return number(begin);
        }
    }

    int number(State &begin) {
        int ret = 0;
        while (*begin == ' ') begin++;
        while (isdigit(*begin)) {
            ret *= 10;
            ret += *begin - '0';
            begin++;
        }
        return ret;
    }

    void deletespace(State &begin) {

    }

    void solve() {
        input();
        int n;
        cin >> n;

        for (int i = 0; i < n; ++i) {
            string s;
//            cin.ignore(0);
//            getline(cin, s);
            cin >> s;

            State begin = s.begin();
            int ans = expression(begin);
            cout << ans << endl;
        }

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int roc = 0;
string s;
int insu();
int kou();
int shiki();

int insu() {
	if(s[roc] >= '0' && s[roc] <= '9') {
		int j = roc;
		while(roc < s.size() && s[roc] >= '0' && s[roc] <= '9') ++roc;
		return stoi(s.substr(j, roc - j));
	} else {
		++roc;
		int res = shiki();
		++roc;
		return res;
	}
}

int kou() {
	int res = insu();
	while (s[roc] == '*' || s[roc] == '/') {
		if(s[roc] == '*') res *= insu();
		else res /= insu();
	}
	return res;
}

int shiki() {
	int res = kou();
	while (s[roc] == '+' || s[roc] == '-') {
		if(s[roc] == '+') res += insu();
		else res -= insu();
	}
	return res;
}

int main(void) {
	int n;
	cin>>n;
	REP(roop, n) {
		roc = 0;
		cin>>s;
		s.pop_back();
		cout<<shiki()<<endl;
	}
}

C++: #include <string>
#include <iostream>
#include <cctype>
#include <cassert>
using namespace std;
int parse();
size_t cur = 0; // 解析開始位置
string S;

char readchar() {
  assert(cur < S.size());
  char ret = S[cur];
  cur += 1;
  return ret;
  // return S[cur++]; と一行で書くこともできる
}
char peek() { // 1 文字読むが cur を進めない
  assert(cur < S.size());
  return S[cur];
}

int digit() {
  assert(isdigit(peek())); // S[cur] が数字であることを確認
  int n = readchar() - '0'; // ’0’ を 0 に変換
  return n;
}

int number() {
  int n = digit();
  while (cur < S.size() && isdigit(peek())) // 次も数字か 1 文字先読
    n = n*10 + digit();
  return n;
}

int factor();
int term() {
  int a = factor();
  while (cur < S.size() && peek() != ')' && (peek() == '*' || peek() == '/')) {
    char op = readchar();
    int b = factor();
    if (op == '*') a *= b; else a /= b;
  }
  return a;
}

int expression(); // 前方宣言
int factor() {
  if (peek() != '(') return number();
  cur += 1;
  int n = expression();
  assert(peek() == ')');
  cur += 1;
  return n;
}

int expression() {
  int a = term();
  while (cur < S.size() && (peek() == '+' || peek() == '-')) { // 足し算か引き算が続く間
    char op = readchar();
    int b = term();
    if (op == '+') {
      a += b;
    }
    else
    {
      a -= b;
    }
  }
  return a;
}



int parse() { return expression(); }
int main() {
  int N;
  cin >> N;
  for (int i=0; i<N; ++i) {
    cur = 0;
    cin >> S;
    S.resize(S.size()-1); // 最後の=を無視
  cout << expression() << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)
#define big (long long int)(10e9 + 7)

int siki(string &str, int &i);
int kou(string &str, int &i);
int insu(string &str, int &i);
int number(string &str, int &i);

int main(void) {
	int num = 0;
	cin >> num;
	rep(0, num) {
		string str;
		int x = 0;
		cin >> str;
		cout << siki(str, x) << endl;
	}
}

int siki(string &str,int &i) {
	int val1 = kou(str,i);
	if (str[i] == '+' || str[i] == '-') {
		char op = str[i];
		i++;
		int val2 = kou(str, i);
		if (op == '+') {
			val1 = val1 + val2;
		}
		else
		{
			val1 = val1 - val2;
		}
	}
	return val1;
}

int kou(string &str, int &i) {
	int val1 = insu(str, i);
	if (str[i] == '*' || str[i] == '/') {
		char op = str[i];
		i++;
		int val2 = insu(str, i);
		if (op == '*') {
			val1 = val1 * val2;
		}
		else {
			val1 = val1 / val2;
		}
	}
	return val1;
}

int insu(string &str, int &i) {
	int val1 = 0;

	if(str[i] != '(')val1 = number(str, i);
	if(str[i] == '(') {
		i++;
		val1 += siki(str, i);
		i += 1;
	}

	
	
	return val1;
}

int number(string &str, int &i) {
	int val1 = 0;
	if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			 val1 = (int)str[i] - (int)'0';
		i++;
		if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			val1 = val1 * 10;
			val1 += number(str, i);
		}
	}
	return val1;
}