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 <string>
#include <cctype>

using namespace std;

string str;
int cur = 0;

int expression();
int term();
int factor();

int expression();

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

int number() {
    int a = digit();
    while (cur < str.size() && isdigit(str[cur])) {
        a = a * 10 + digit();
    }
    return a;
}

int expression() {
    int a = term();
    while (cur < str.size() && (str[cur] == '+' || str[cur] == '-')) {
        if (str[cur] == '+') {
            cur++;
            int b = term();
            a += b;
        } else if (str[cur] == '-') {
            cur++;
            int b = term();
            a -= b;
        }
    }
    return a;
}

int term() {
    int a = factor();
    while (cur < str.size() && (str[cur] == '*' || str[cur] == '/')) {
        if (str[cur] == '*') {
            cur++;
            int b = factor();
            a *= b;
        } else if (str[cur] == '/') {
            cur++;
            int b = factor();
            a /= b;
        }
    }
    return a;
}

int factor() {
    if (str[cur] != '(') return number();
    cur++;
    int a = expression();
    cur++;
    return a;
}

int main() {
    int N = 0;
    cin>>N;
    for (int n = 0; n < N; n++) {
        cin>>str;
        cur = 0;
        cout<<expression()<<endl;
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int calc(char *s, int &i){
  int ret = 0;
  bool flag = i >= 0 && s[i-1] == '(';

  //debug(s[i]);
  
  for(;s[i];){
    
    if(s[i] == ')'){
      if(flag) i++;
      return ret;
    }
    
    if(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/'){

      i++;
      
      if(s[i] == '('){
        i++;

        if(i-2 < 0) ret += calc(s,i);
        if(s[i-2] == '+') ret += calc(s,i);
        if(s[i-2] == '-') ret -= calc(s,i);
        if(s[i-2] == '*') ret *= calc(s,i);
        if(s[i-2] == '/') ret /= calc(s,i);

        continue;
      }

            
      if(s[i-1] == '+') ret += calc(s,i);
      if(s[i-1] == '-') ret -= calc(s,i);
      
    }else{
      int start = i-1;
      int sum = 0;
      
      while(!(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/' || s[i] == '\0' || s[i] == ')')){
        sum *= 10;
        sum += s[i] - '0';
        i++;
      }

      if(start < 0){
        ret += sum;
      }else{
        if(s[start] == '(') ret += sum;
        if(s[start] == '+') ret += sum;
        if(s[start] == '-') ret += sum;
        if(s[start] == '*') ret *= sum;
        if(s[start] == '/') ret /= sum;
      }
    }
  }
  
  return ret;
}


int main(){
  char s[SIZE];
  int t = 0;

  int n;

  scanf("%d",&n);

  while(n--){
    char s2[SIZE] = {};
    t = 0;
    scanf("%s",s);

    s[strlen(s)-1] = '\0';

    strcat(s2,"0+");
    strcat(s2,s);
    
    printf("%d\n",calc(s2,t));
  }
  
  return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

string s;
int p;

int expression();
int term();
int factor();
int number();

int expression() {
	int value = term();
	while(true) {
		if(s[p] == '+') {
			p++;
			value += term();
		} else if(s[p] == '-') {
			p++;
			value -= term();
		} else {
			break;
		}
	}
	return value;
}

int term() {
	int value = factor();
	while(true) {
		if(s[p] == '*') {
			p++;
			value *= factor();
		} else if(s[p] == '/') {
			p++;
			value /= factor();
		} else {
			break;
		}
	}
	return value;
}

int factor() {
	int value = 0;
	if(s[p] == '(') {
		p++;
		value = expression();
		p++;
	} else {
		value = number();
	}
	return value;
}

int number() {
	int value = 0;
	while(isdigit(s[p])) {
		value = value*10 + (s[p] - '0');
		p++;
	}
	return value;
}

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

	return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>

#define rep(i,n)  for(int i=0;i<n;++i)

using namespace std;

string src;
int pos;

bool end() { return pos >= src.length(); }
char peek() { return src[pos]; }
void succ() { if (!end()) ++pos; }

int parse_expr();

int lex_number()
{
	int val = 0;
	char c = peek();
	do
	{
		val = 10 * val + (c - '0');
		succ();
	}
	while (!end() && isdigit(c = peek()));
	return val;
}

int parse_primary()
{
	int ret;

	char c = peek();
	switch (c)
	{
	case '(':
		succ();
		ret = parse_expr();
		succ();
		break;
	default:
		ret = lex_number();
		break;
	}
	return ret;
}

int parse_term()
{
	int x = parse_primary();
	while (!end() && (peek() == '*' || peek() == '/'))
	{
		char op = peek();
		succ();
		int y = parse_primary();
		x = (op == '*' ? x * y : x / y);
	}
	return x;
}

int parse_expr()
{
	int x = parse_term();
	while (!end() && (peek() == '+' || peek() == '-'))
	{
		char op = peek();
		succ();
		int y = parse_term();
		x = (op == '+' ? x + y : x - y);
	}
	return x;
}

int parse()
{
	pos = 0;
	return parse_expr();
}

int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		cin >> src;
		cout << parse() << endl;
	}
	return 0;
}

C++: #include <iostream>

int main()
{
std::cout << std::endl;
return 0;
}

C++: #include <iostream>

using namespace std;

int r;
int i;
int sd(char *s, int m){
    int n = 0, d = 0;
    for(;s[i] != '\0';){
        switch(s[i]){
        case '=':
            return n;
        case '+':
            if(m == 1)
                return n;
            i++;
            return n + sd(s, 2);
        case '-':
            if(m == 1)
                return n;
            i++;
            return n - sd(s, 2);
        case '*':
            i++;
            return n * sd(s, 1);
        case '/':
            i++;
            return n / sd(s, 1);
        case '(':
            i++;
            return sd(s, 0);
        case ')':
            i++;
            return n;
        default:
            n = n * 10 + s[i] - '0';
            i++;
            break;
        }
    }
}

int main(void)
{
    int N;

    cin >> N;
    char str[1024];


    for(int k = 0; k < N; k++){
        r = 0;
        i = 0;
        cin >> str;
        printf("%d", sd(str, 0));
    }
}