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 <vector>
#include <cmath> // ??????
 
#define REP(i,n) for(int i = 0; i < n; i++)
 
using namespace std;
 
struct FourArithmeticOperationParser {
    
    int pos;
    bool div_zero;
    string Formula;
    const long long INF = 0x7fffffffffffffff;
    
    long long operator () (string F) {
        pos = 0;
        div_zero = false;
        Formula = F;
        long long ret = expr();
        return div_zero ? INF : ret;
    }
    
    long long number() {
        long long ret = 0;
        while (pos != Formula.size()) {
            if (Formula[pos] < '0' || Formula[pos] > '9') {
                break;
            } else {
                ret *= 10;
                ret += (Formula[pos++] - '0');
            }
        }
        return ret;
    }
    
    long long expr() {
        long long x = term();
        while (pos < Formula.size()) {
            switch (Formula[pos]) {
                case '+':
                    pos++;
                    x += term();
                    continue;
                case '-':
                    pos++;
                    x -= term();
                    continue;
            }
            break;
        }
        return x;
    }
    
    long long term() {
        long long x = factor();
        while (pos < Formula.size()) {
            switch (Formula[pos]) {
                case '*':
                    pos++;
                    x *= factor();
                    continue;
                case '/':
                    pos++;
                    long long div = factor();
                    if (div == 0) {
                        div_zero = true;
                    } else {
                        x /= div;
                    }
                    continue;
            }
            break;
        }
        return x;
    }
    
    long long factor() {
        if (pos < Formula.size()) {
            if (Formula[pos] == '(') {
                pos++;
                long long ret = expr();
                if (Formula[pos] == ')') {
                    pos++;
                }
                return ret;
            }
        }
        return number();
    }
    
};
 
int main() {
    
    int N; cin >> N;
    REP(i,N) {
        string s; cin >> s;
        cout << FourArithmeticOperationParser()(s.substr(0,s.size() - 1)) << endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;

int num(string&, int&);
int term(string&, int&);
int mul(string&, int&);
int expr(string&, int&);

int num(string &s, int &k) {
    int ret = 0;
    while ('0' <= s[k] && s[k] <= '9') {
        ret *= 10;
        ret += s[k] - '0';
        k ++;
    }
    return ret;
}

int term(string &s, int &k) {
    int sym = 1;
    if (s[k] == '+') {
        sym = 1;
        k ++;
    } else if (s[k] == '-') {
        sym = -1;
        k ++;
    }
    int ret;
    if (s[k] == '(') {
        k ++;
        ret = expr(s, k);
        k ++;
    } else {
        ret = num(s, k);
    }
    return sym * ret;
}

int mul(string &s, int &k) {
    int ret = term(s, k);
    if (s[k] == '*') {
        k ++;
        return ret * mul(s, k);
    } else if (s[k] == '/') {
        k ++;
        return ret / mul(s, k);
    }
    return ret;
}

int expr(string &s, int &k) {
    int ret = mul(s, k);
    if (s[k] == '+') {
        k ++;
        return ret + expr(s, k);
    } else if (s[k] == '-') {
        return ret + expr(s, k);
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    string s;
    while (n--) {
        cin >> s;
        int pos = 0;
        cout << expr(s, pos) << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int calc(char *s, char *end)
{
	/*for (char *p = s; p != end; p++) printf("%c", *p);
	puts("");*/
	
	vector<int> st;
	vector<char> op;
	
	char *p = s;
	while (p != end){
		if (*p == '+' || *p == '-' || *p == '*' || *p == '/'){
			op.push_back(*p);
			p++;
			continue;
		}
		if (*p >= '0' && *p <= '9'){
			int n = atoi(p);
			st.push_back(n);
			stringstream ss;
			ss << n;
			p += ss.str().size() - 1;
		}
		else if (*p == '('){
			char *e;
			for (e = p + 1; *e != ')'; e++);
			st.push_back(calc(p + 1, e));
			p = e;
		}
		if (op.size() && (op.back() == '*' || op.back() == '/')){
			int b = st.back(); st.pop_back();
			int a = st.back(); st.pop_back();
			if (op.back() == '*') a *= b;
			if (op.back() == '/') a /= b;
			st.push_back(a);
			op.pop_back();
		}
		p++;
		
		/*printf("__");
		for (auto a : st) printf("%d ", a);
		puts("");*/
	}
	
	while (op.size()){
		int t = st.front(); st.erase(st.begin());
		if (op.front() == '+') st[0] = t + st[0];
		if (op.front() == '-') st[0] = t - st[0];
		op.erase(op.begin());
	}
	
	return st[0];
}

int main()
{
	int n;
	char str[1024];
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%s", str);
		str[strlen(str) - 1] = '\0';
		printf("%d\n", calc(str, str + strlen(str)));
	}
	
	return 0;
}

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

int lp=0;
int solve(string str){
    vector<int>op;
    vector<char>ope;
    //cout<<str.length()<<endl;
    for(int i=0;i<str.length();i++){
        //cout<<"KK";
        if(str[i]=='('){
            string t;
            i++;
            lp++;
            while(lp){
                t+=str[i];
                i++;
                if(str[i]=='(')lp++;
                if(str[i]==')')lp--;
            }
            i++;
            op.push_back(solve(t));
            //cout<<"(): "<<ope[ope.size()-1]<<endl;
            if(ope.size())
            if(ope[ope.size()-1]=='*'||ope[ope.size()-1]=='/'){
                int a=op[op.size()-1];
                op.pop_back();
                int b=op[op.size()-1];
                op.pop_back();
                if(ope[ope.size()-1]=='*')op.push_back(a*b);
                else op.push_back(b/a);
                ope.pop_back();
            }
            ope.push_back(str[i]);
        }
        else if(str[i]>='0'&&str[i]<='9'){
            int g=0;
            while(str[i]>='0'&&str[i]<='9'){
                g=g*10+str[i]-'0';
                i++;
            }
            op.push_back(g);
            if(ope.size())
                if(ope[ope.size()-1]=='*'||ope[ope.size()-1]=='/'){
                    int a=op[op.size()-1];
                    op.pop_back();
                    int b=op[op.size()-1];
                    op.pop_back();
                    if(ope[ope.size()-1]=='*')op.push_back(a*b);
                    else op.push_back(b/a);
                    ope.pop_back();
                }
            if(str[i])ope.push_back(str[i]);
        }
    }
    //cout<<"!"<<endl;
    int las=op[op.size()-1];
    op.pop_back();
    while(ope.size()){
        //cout<<"las: "<<las<<endl;
        char c=ope[ope.size()-1];
        ope.pop_back();
        if(c=='=')continue;
        int pre=op[op.size()-1];
        //cout<<"pre: "<<pre<<endl;
        //cout<<ope.size()<<"   c: "<<c<<endl;
        op.pop_back();
        if(c=='+')las=las+pre;
        else las=pre-las;
    }
    //cout<<"returned : "<<las<<endl;
    return las;
}

int main(){
    int n;
    cin>>n;
    while(n--){
        string str;
        cin>>str;
        cout<<solve(str)<<endl;
    }
}