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<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(l,r,i) for(int i=l;i<r;i++)
#define P pair<int,int>
#define ll long long 

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

int number(State &begin);
int factor(State &begin);
int term(State &begin);
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){
    int ret=0;

    if(*begin=='('){
        begin++;
        ret=expression(begin);
        begin++;
    }
    else{
        ret=number(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 main(){

    int n;
    cin>>n;
    cin.ignore();
    for(int i=0;i<n;i++){
        string s;
        getline(cin,s);
        State begin=s.begin();
        cout<<expression(begin)<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <utility>
#include <cstdlib>
#include <cctype>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct calc {
	char c;

	calc() {
		c = gcu();
	}

	bool consume(char e) {
		if (c != e)
			return false;
		else {
			c = gcu();
			return true;
		}
	}

	int number() {
		if (isdigit(c)) {
			int d;
			ungetc(c, stdin);
			scanf("%d", &d);
			c = gcu();
			return d;
		} else {
			fprintf(stderr,"ERROR: expected number\n, but got %c\n", c);
			exit(0);
		}
	}

	int mul() {
		int a = term();
		for (;;)
			if (consume('*'))
				a *= term();
			else if (consume('/'))
				a /= term();
			else
				return a;
	}

	int add() {
		int a = mul();
		for (;;)
			if (consume('+'))
				a += mul();
			else if (consume('-'))
				a -= mul();
			else
				return a;
	}

	int term() {
		if (consume('(')) {
			int a = add();
			consume(')');
			return a;
		} else
			return number();
	}


	int exec() {
		int n = add();
		if (consume('='))
			return n;
		else {
			fprintf(stderr,"ERROR: expected =, but got %c\n", c);
			exit(0);
		}
	}
};

int main() {
	for (int n = in(); n; n--) {
		calc c = calc();
		outl(c.exec());
	}
}

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

inline string sub(string str, int i) {
    return string(str.begin() + i + 1, str.end());
}

int dfs(string);
int get_num(string&, int&);

int get_num(string& str, int& i) {
    int num = 0;

    if (str[i] == '(') {
        string ss;
        i++;
        for (int count = 1; count; i++) {
            if (str[i] == '(') count++;
            if (str[i] == ')') count--;

            if (count) {
                ss += str[i];
            }
        }

        if (str[i] != ')') i--;
        return dfs(ss);
    }

    for (; i < str.size(); i++) {
        if ('0' <= str[i] && str[i] <= '9') {
            num = num * 10 + (str[i] - '0');
        } else {
            return num;
        }
    }

    return num;
}

int dfs(string str) {
    int num = 0;

    int i = 0;

    if (str[i] == '-') {
        num = -1 * get_num(str, ++i);
    }

    if (str[0] == '(') {
        num = get_num(str, i);
    }

    for (; i < str.size(); i++) {
        if ('0' <= str[i] && str[i] <= '9') {
            num = num * 10 + (str[i] - '0');
        } else {
            if (str[i] == '*') {
                num = num * get_num(str, ++i);
            } else if (str[i] == '/') {
                num = num / get_num(str, ++i);
            } else if (str[i] == '+') {
                return num + dfs(sub(str, i));
            } else if (str[i] == '-') {
                return num - dfs(sub(str, i));
            } if (str[i] == ')') {
                continue;
            } else {
                return num;
            }
        }
    }

    return num;
}

int main() {
    int N;
    cin >> N;
    while (N--) {
        string str;
        cin >> str;

        cout << dfs(str) << endl;
    }

    return 0;
}

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

inline string sub(string str, int i) {
    return string(str.begin() + i + 1, str.end());
}

int dfs(string);
int get_num(string&, int&);

int get_num(string& str, int& i) {
    int num = 0;

    if (str[i] == '(') {
        string ss;
        i++;
        for (int count = 1; count; i++) {
            if (str[i] == '(') count++;
            if (str[i] == ')') count--;

            if (count) {
                ss += str[i];
            }
        }

        i--;
        return dfs(ss);
    }

    for (; i < str.size(); i++) {
        if ('0' <= str[i] && str[i] <= '9') {
            num = num * 10 + (str[i] - '0');
        } else {
            return num;
        }
    }
    i--;

    return num;
}

int dfs(string str) {
    int num = 0;

    int i = 0;

    if (str[i] == '-') {
        num = -1 * get_num(str, ++i);
    }

    if (str[0] == '(') {
        num = get_num(str, i);
    }

    for (; i < str.size(); i++) {
        if ('0' <= str[i] && str[i] <= '9') {
            num = num * 10 + (str[i] - '0');
        } else {
            if (str[i] == '*') {
                num = num * get_num(str, ++i);
            } else if (str[i] == '/') {
                num = num / get_num(str, ++i);
            } else if (str[i] == '+') {
                return num + dfs(sub(str, i));
            } else if (str[i] == '-') {
                return num - dfs(sub(str, i));
            } else {
                return num;
            }
        }
    }

    return num;
}

int main() {
    int N;
    cin >> N;
    while (N--) {
        string str;
        cin >> str;

        cout << dfs(str) << endl;
    }

    return 0;
}