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<cassert>
#include<cctype>
using namespace std;
string S;
int cur;
int expression();
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 factor(){
    if(S[cur]!='(') return number();
    cur+=1;
    int n=expression();
    assert(S[cur]==')');
    cur+=1;
    return n;
}
int term(){
    int a=factor();
    while(cur<S.size()&&(S[cur]=='*'||S[cur]=='/')){
        char op=S[cur++];
        int b=factor();
        if(op=='*'){
            a*=b;
        }
        else a/=b;
    }
    return a;
}
int expression() {
    int sum=term();
    while(cur<S.size()&&(S[cur]=='+'||S[cur]=='-')){
        char op=S[cur++];
        int b=term();
        if(op=='+'){
            sum+=b;
        }
        else sum-=b;
    }
    return sum;
}
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        cur=0;
        cin>>S;
        cout<<expression()<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int eval(const string & expr) {
	int left = 0;
	int right = 0;
	int mdtemp = 0;
	int ev_idx = 0;
	int sign = 1; // 1=+, -1=-
	char c, cc;

	// 項の処理
	while((c = expr[ev_idx++]) != '\0') {
		if(c == '+' || c == '-') {
			left += sign * right;
			right = 0;
			if(c == '+') sign = 1;
			else sign = -1;
		} else if(c == '*' || c == '/') { // if mul,div
			mdtemp = 0;
			while(1) {
				if((cc = expr[ev_idx++]) == '\0' || cc == '+' || cc == '-' || cc == '*' || cc == '/') {
					ev_idx--;
					break;
				}
				if(cc == '(') {
					int clen = 0;
					int cstrt = ev_idx;
					while(expr[ev_idx++] != ')') clen++;
					string ceval = expr.substr(cstrt, clen);
					mdtemp = eval(ceval);
				} else {
					mdtemp *= 10;
					mdtemp += (int)(cc - '0');
				}
			}
			if(c == '*') right *= mdtemp;
			else right /= mdtemp;
		} else if(c == '(') {
			int clen = 0;
			int cstrt = ev_idx;
			while(expr[ev_idx++] != ')') clen++;
			string ceval = expr.substr(cstrt, clen);
			right = eval(ceval);
		} else { // if numbers
			right *= 10;
			right += (int)(c - '0');
		}
	}
	left += sign * right;
	
	return left;
}

int main() {
	int n;
	cin >> n;
	
	vector<int> anss(n);

	for(int i=0;i<n;i++) {
		string expr;
		cin >> expr;
		int ans;
		ans = eval(expr);
		anss[i] = ans;
	}
	for(auto it = anss.begin(); it != anss.end(); it++) {
		cout << *it << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<functional>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef string::const_iterator State;
int Factor(State& begin);

int numParse(State& begin){
    int tmp=0;
    bool f=false;
    if(*begin=='-')f=true;
    while(isdigit(*begin)){
        tmp*=10;
        tmp+=*begin-'0';
        begin++;
    }
    if(*begin=='=')begin++;
    return f ? -tmp:tmp;
}
int MulDiv(State& begin){
    int tmp=Factor(begin);
    while(1){
        if(*begin=='*'){
            begin++;
            tmp *= Factor(begin);
        }else if(*begin=='/'){
            begin++;
            tmp /= Factor(begin);
        }else{
            break;
        }
    }
    return tmp;
}

int AddSub(State& begin){
    int tmp=MulDiv(begin);
    while(1){
        if(*begin=='+'){
            begin++;
            tmp+=MulDiv(begin);
        }else if(*begin=='-'){
            begin++;
            tmp-=MulDiv(begin);
        }else {
            break;
        }
    }
    return tmp;
}

int Factor(State& begin){
    if(*begin=='('){
        begin++;
        int tmp=AddSub(begin);
        begin++;
        if(*begin=='=')begin++;
        return tmp;
    }else{
        return numParse(begin);
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s2;
        cin>>s2;
        string s1="0";
        if(s2[0]!='-')s1+="+";
        string s=s1+s2;
        State begin=s.begin();
        int ans=AddSub(begin);
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <cctype>


using namespace std;

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

int expression(State &begin);

//数字の列をパースして、その数を返す。
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);
	}
}

//乗除の式をパースして、その評価結果を返す。
int term(State &begin){
	int ret = factor(begin);

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

	return ret;
}

//四則演算の式をパースして、その評価結果を返す。
int expression(State &begin){
	int ret = term(begin);

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

	return ret;
}

int main(){
	int I[100],Ii=0,n;
	string s;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> s;
		
		State begin = s.begin();
		int ans = expression(begin);
		I[Ii++] = ans;
	}

	for(int i=0;i<n;i++){
		cout << I[i] << endl;
	}

	return 0;
}