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 <algorithm>
#include <cstdlib>
using namespace std;

string s;
string::iterator p;

int fact();
int term();
int exp();

int fact() {
  int x;
  string num;
  while(isdigit(*p)) {
    num += *p;
    ++p;
  }
  if(num.size()) {
    x = atoi(num.c_str());
  } else {
    ++p;
    x = exp();
    ++p;
  }
  return x;
}

int term() {
  int x = fact();
  while(*p == '*' || *p == '/') {
    if(*p == '*') {
      ++p;
      x *= fact();
    } else {
      ++p;
      x /= fact();
    }
  }
  return x;

}

int exp() {
  int x = term();
  while(*p == '+' || *p == '-') {
    if(*p == '+') {
      ++p;
      x += term();
    } else {
      ++p;
      x -= term();
    }
  }
  return x;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    cin >> s;
    p = s.begin();
    cout << exp() << endl;
  }
  return 0;
}

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

map<char,int> order;
string S; size_t cur=0;
stack<int> num,rnum;
stack<char> op,rop;

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

int number(){
	int n=digit();
	while(isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

void calc(){
	int b=num.top();num.pop();
	int a=num.top();num.pop();
	char o=op.top();op.pop();
	int c;
	switch(o){
		case '+' :
			c=a+b;
			break;
		case '-' :
			c=a-b;
			break;
		case '*' :
			c=a*b;
			break;
		case '/' :
			c=a/b;
			break;
		default :
			break;
	}
	num.push(c);
	return ;
}

void calc2(){
	int a=rnum.top();rnum.pop();
	int b=rnum.top();rnum.pop();
	char o=rop.top();rop.pop();
	int c;
	switch(o){
		case '+' :
			c=a+b;
			break;
		case '-' :
			c=a-b;
			break;
		case '*' :
			c=a*b;
			break;
		case '/' :
			c=a/b;
			break;
		default :
			break;
	}
	rnum.push(c);
	return ;
}

int exp(){
	cur =0;
	int smax=S.size();
	while(cur < smax-1){
		//cout << cur << endl;
		if(isdigit(S[cur])){
			int a=number();
			num.push(a);
		}else if(!op.empty()&&op.top()!='('&&op.top()!=')'&& order[S[cur]] > order[op.top()]){ //計算順序については改善の余地あり (　は最小に
			calc();
			op.push(S[cur++]);
		}else if(S[cur] == ')' ){
			if(!op.empty()&&op.top()!='(')
				calc();
			rnum.push(num.top());num.pop();
 			while(!op.empty()&&op.top()!='('){
				rop.push(op.top());op.pop();
				rnum.push(num.top());num.pop();
			}
			while(!rop.empty())
				calc2();
			num.push(rnum.top());rnum.pop();
			//cout << num.top() << endl;
			op.pop();cur++;
		}else{//ひとまず終了　演算記号のチェックも入れる
			//	cout << "come" << endl;
			op.push(S[cur++]);
		}
	}

	if(op.size()>=2){
		char op1,op2;
		op1=op.top();op.pop();op2=op.top();
		op.push(op1);
		if(order[op1]<order[op2])
			calc();
	}
	cout << num.top() << endl;//
	int tmp1=num.top();num.pop();
	cout << num.top() << endl;//
	int tmp2=num.top();num.pop();
	cout << num.top() << endl;//
	num.push(tmp2);
	num.push(tmp1);

	rnum.push(num.top());num.pop();
	while(!op.empty()&&op.top()!='('){
		rop.push(op.top());op.pop();
		rnum.push(num.top());num.pop();
	}
	while(!rop.empty())
		calc2();
	num.push(rnum.top());rnum.pop();
	//cout<< " check "  << op.empty() << endl;
	int ans=num.top();
	num.pop();
	return ans;
}

int main(void){
	order['+']=2;
	order['-']=2;
	order['*']=1;
	order['/']=1;
	//cout << order['('] << endl;
	int n;
	cin >> n;
	while(n--){
		cin >> S;
		cout << exp() << endl;
	}
	return 0;
}

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

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

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

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

    return ret;
}

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

    for (;;) {
        if (*begin == '*') {
            begin++;
            ret *= number(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= number(begin);
        } else {
            break;
        }
    }

    return ret;
}

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

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

    return ret;
}


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;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

string s;
int p;

int expr();

int num() {
  int res = 0;
  while (p < s.size() && '0' <= s[p] && s[p] <= '9') {
    res *= 10;
    res += s[p] - '0';
    p++;
  }
  return res;
}

int factor() {
  int res = 0;
  if (s[p] == '(') {
    p++;
    res = expr();
    p++;
  } else {
    res = num();
  }
  return res;
}

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

int expr() {
  int res = term();
  while (p < s.size()) {
    if (s[p] == '+') {
      p++;
      res += term();
    } else if (s[p] == '-') {
      p++;
      res -= term();
    } else {
      break;
    }
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    cin >> s;
    p = 0;
    cout << expr() << endl;
  }
}