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 <iostream>
#include <string>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
class ParseError {};

int expression(State &);
int term(State &);
int number(State &);
int factor(State &);

int main(void) {
    int N;
    cin >> N;
    cin.ignore();
    for (int i = 0; i < N; i++) {
        string s;
        getline(cin, s);

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

    return 0;
}

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

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

    return ret;
}

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

    while (1) {
        if (*begin == '*') {
            begin++;
            ret *= factor(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }

    return ret;
}

int number(State &begin) {
    int ret = 0;

    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}

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

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int term(char* &s);
int number(char* &s);
int factor(char* &s);
int expr(char* &s);


//数
int number(char* &s){
  int res = 0;

  while('0' <= *s && *s <= '9')
    res = res*10 + (*s++ - '0');

  return res;
}


//乗算除算
int term(char* &s){
  int res = factor(s);

  while(1){
    if(*s == '*') res *= factor(++s);
    else if(*s == '/') res /= factor(++s);
    else break;
  }

  return res;
}

//式
int expr(char* &s){
  int res = term(s);

  while(1){
    if(*s == '+') res += term(++s);
    else if(*s == '-') res -= term(++s);
    else break;
  }

  return res;
}

//括弧か数
int factor(char * &s){
  if(*s != '(') return number(s);
  int res = 0;  
  res = expr(++s); s++;
  return res;
}




int main(){
  int n;

  scanf("%d", &n);

  while(n--){
    char s[SIZE];
    cin >> s;
    for(int i=0;i<n;i++) if(s[i] == '=') s[i] = '\0';
    char *p = s;
    cout << expr(p) << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <cassert>
#include <string>
#include <cctype>

using namespace std;
int cur = 0;
string S;
int expression();
int term();
int factor();
int main() {
  int times;
  cin >>times;
  for(int i = 0 ; i < times; i++){
      cin >> S;
      cur = 0;
      S.resize(S.size()-1);
      cout << expression() <<endl;
  }

}
int digit() {
  assert(isdigit(S[cur]));
  int n = S[cur] -'0';
  cur = cur+1;
  return n;
}
int number() {
  int n = digit();
  while(cur <S.size() && isdigit(S[cur])){
      n = n*10 + digit();
  }
  return n;
}
int expression() {
  int sum = term();
  while (S[cur] == '+' || S[cur] == '-'){
    char op = S[cur];
    cur +=1;
    int b = term();
    if(op ==  '+') sum +=b;
    else sum -= b;
  }
  return sum;
}
int term() {
  int a = factor();
  while(cur < S.size()
        && (S[cur] == '*' || S[cur] == '/')){
          char op = S[cur];
          cur +=1;
          int b = factor();
          if(op == '*') a *=b;
          else a/=b;
        }
  return a;
}
int factor() {
  if(S[cur] != '(' ) return number();
  cur +=1;
  int n =expression();
  assert(S[cur] == ')');
  cur +=1;
  return n;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;

int p;
string S;

int num();
int factor();
int term();
int calc();

int num(){
	int n = 0;
	while(p<S.size()){
		if(isdigit(S[p])) n = n*10+S[p]-'0';
		else break;
		p++;
	}
	return n;
}

int factor(){
	int n;
	if(S[p]=='('){
		p++; n = calc(); p++;
	}
	else n = num();
	return n;
}

int term(){;
	int n = factor();
	while(p<S.size()){
		if(S[p]=='*') p++, n *= factor();
		else if(S[p]=='/') p++, n /= factor();
		else break;
	}
	return n;
}

int calc(){
	int n = term();
	while(p<S.size()){
		if(S[p]=='+') p++, n += term();
		else if(S[p]=='-') p++, n -= term();
		else break;
	}
	return n;
}

int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>S; S.pop_back();
		p = 0;
		printf("%d\n",calc());
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cassert>
#include <cctype>
using namespace std;

string S;
size_t cur = 0;
int expression();
int digit();
int number();
int parse();
int term();
int factor();

int main(){
  int n;
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> S;
    int a = parse();
    //  assert (a == 15);
    assert (cur == S.size()-1);
    cout << a << endl;
    cur = 0;
  }
}

int digit(){
  assert (isdigit(S[cur]));
  int n = S[cur] - '0';
  cur = cur+1;
  return n;
}

int number(){
  int n = digit();
  while(cur < S.size()-1 && isdigit(S[cur]))
    n = n*10 + digit();
  return n;
}

int expression(){
  int sum = term();
  while (S[cur] == '+' || S[cur] == '-'){
    char op = S[cur];
    cur += 1;
    int b = term();
    assert(op == '+' || op == '-');
    if (op == '+')  sum += b;
    else sum -= b;
  }
  return sum;
}

int term(){
  int a = factor();
  while ( cur < S.size()-1 && (S[cur] == '*' || S[cur] == '/') ){
    char op = S[cur++];
    int b = factor();
    if (op == '*') a *= b; else a /= b;
  }
  return a;
}

int factor(){
  if (S[cur] != '(') return number();
  cur += 1;
  int n = expression();
  assert(S[cur] == ')');
  cur += 1;
  return n;
}

int parse(){
  return expression();
}