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++: //???2:negFLG?°???\???
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int n,tmp,op1,work,count,work2;
	char line[101],calc;
	stack<int> NUM,work_num;
	stack<char> OP,work_op;

	bool numFLG,negFLG;

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s",line);

		tmp = 0;
		numFLG = false;
		negFLG = false;

		for(int k = 0; line[k] != '\0'; k++){
			if(line[k] >= '0' && line[k] <= '9'){
				numFLG = true;
				tmp = 10*tmp + (line[k] - '0');

			}else{

				if(numFLG == true){

					if(negFLG){
						tmp = -1*tmp;
						negFLG = false;
					}

					if(OP.empty() == false && (OP.top() == '*' || OP.top() == '/')){
						calc = OP.top();
						OP.pop();
						op1 = NUM.top();
						NUM.pop();

						if(calc == '*'){
							NUM.push(tmp*op1);
						}else{
							NUM.push(op1/tmp);
						}
					}else{
						NUM.push(tmp);
					}

					numFLG = false;
					tmp = 0;
				}

				if(line[k] == '+' ||line[k] == '*' || line[k] == '/' || line[k] == '('){
					OP.push(line[k]);
				}else if(line[k] == '-'){

					if(k == 0){
						if(line[k+1] != '('){
							negFLG = true;
						}else{
							NUM.push(-1);
							OP.push('*');
						}
					}else if(line[k-1] == '(' && line[k+1] == '('){
						NUM.push(-1);
						OP.push('*');
					}else if(k > 0 && (line[k-1] == '+' || line[k-1] == '-' || line[k-1] == '*' || line[k-1] == '/' || line[k-1] == '(')){
						negFLG = true;
					}else{
						OP.push('-');
					}
				}else if(line[k] == ')'){

					work = NUM.top();
					NUM.pop();
					work_num.push(work);

					count = 0;

					while(true){
						calc = OP.top();
						OP.pop();
						if(calc == '(')break;

						count++;

						work_op.push(calc);

						work = NUM.top();
						NUM.pop();
						work_num.push(work);
					}

					if(count == 0){
						work = work_num.top();
						work_num.pop();
					}else{

						work = work_num.top();
						work_num.pop();

						while(!work_num.empty()){
							calc = work_op.top();
							work_op.pop();

							if(calc == '+'){
								work += work_num.top();
							}else if(calc == '-'){
								work -= work_num.top();
							}else if(calc == '*'){
								work *= work_num.top();
							}else{
								work /= work_num.top();
							}
							work_num.pop();
						}
					}

					if(OP.empty() == false && OP.top() == '*'){
						OP.pop();
						work2 = NUM.top();
						NUM.pop();
						work *= work2;
					}else if(OP.empty() == false &&OP.top() == '/'){
						OP.pop();
						work2 = NUM.top();
						NUM.pop();
						work = work2/work;
					}

					NUM.push(work);

				}else{

					work = NUM.top();
					NUM.pop();
					work_num.push(work);

					while(!NUM.empty()){
						calc = OP.top();
						OP.pop();

						work_op.push(calc);

						work = NUM.top();
						NUM.pop();
						work_num.push(work);
					}

					work = work_num.top();
					work_num.pop();

					while(!work_num.empty()){
						calc = work_op.top();
						work_op.pop();

						if(calc == '+'){
							work += work_num.top();
						}else if(calc == '-'){
							work -= work_num.top();
						}else if(calc == '*'){
							work *= work_num.top();
						}else{
							work /= work_num.top();
						}
						work_num.pop();
					}

					printf("%d\n",work);
				}
			}
		}

	}


	return 0;
}

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

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

typedef unsigned long long ull;
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define all(a) (a).begin() ,(a).end()

const double eps = 1e-10;
const double inf = (int)1e8;

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

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

int term(State & begin){
    int ret = factor(begin);
    
    for(;;){
        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);
    
    for(;;){
        if(*begin == '+'){
            begin++;
            ret += term(begin);
        }else if(*begin == '-'){
            begin++;
            ret -= term(begin);
        }else{
            break;
        }
    }
    return ret;
}

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

int main(void){
    int n;
    string s;
    cin>>n;
    getline(cin,s);
    while(n--){
        getline(cin,s);
        State begin = s.begin();
        cout<<expression(begin)<<endl;
    }
}

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

using State = string::const_iterator;

using ll = long long int;

int expr(State &begin);
int term(State &begin);
int num(State &begin);
int factor(State &begin);

void consume(State &begin, char expected){
    if(*begin == expected){
        begin++;
    }else{
        cerr << "Expected " << expected << " but " << *begin << endl;
        throw "";
    }
}

int expr(State &begin){
    int res = term(begin);
    while(1){
        if(*begin == '+'){
            begin++;
            res += term(begin);
        }else if(*begin == '-'){
            begin++;
            res -= term(begin);
        }else{
            break;
        }
    }
    return res;
}

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

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

int factor(State &begin){
    int res = 0;
    if(*begin == '('){
        begin++;
        res = expr(begin);
        consume(begin,')');  // ')'
    }else{
        res = num(begin);
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        State begin = s.begin();
        int ans = expr(begin);
        cout << ans << endl;
    }
    return 0;
}