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 <stack>
#include <map>
#include <string>
#include <cctype>
using namespace std;

map<char,int> order;
string S; size_t cur=0;
stack<int> num;
stack<char> op;

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

int number(){
	int n=digit();
	while(isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

void calc(){
	int b=num.top();num.pop();
	int a=num.top();num.pop();
	char o=op.top();op.pop();
	int c;
	switch(o){
		case '+' :
			c=a+b;
			break;
		case '-' :
			c=a-b;
			break;
		case '*' :
			c=a*b;
			break;
		case '/' :
			c=a/b;
			break;
		default :
			break;
	}
	num.push(c);
	return ;
}

int exp(){
	cur =0;
	int smax=S.size();
	while(cur < smax-1){
		//cout << cur << endl;
		if(isdigit(S[cur])){
			int a=number();
			num.push(a);
		}else if(!op.empty()&&op.top()!='('&&op.top()!=')'&& order[S[cur]] > order[op.top()]){ //計算順序については改善の余地あり (　は最小に
			calc();
			op.push(S[cur++]);
		}else if(S[cur] == ')' ){
 			while(!op.empty()&&op.top()!='(')
				calc();
			//cout << num.top() << endl;
			op.pop();cur++;
		}else{//ひとまず終了　演算記号のチェックも入れる
			//	cout << "come" << endl;
			op.push(S[cur++]);
		}
	}
	while(!op.empty())
		calc();
	//cout<< " check "  << op.empty() << endl;
	int ans=num.top();
	num.pop();
	return ans;
}

int main(void){
	order['+']=2;
	order['-']=2;
	order['*']=1;
	order['/']=1;
	//cout << order['('] << endl;
	int n;
	cin >> n;
	while(n--){
		cin >> S;
		cout << exp() << endl;
	}
	return 0;
}

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

int calculate(string expr) {
	map<char,int> op_pd {{'+',0},{'-',0},{'*',1},{'/',1}}; // operator precedence
	vector<string> pf; // postfix expression
	stack<char> op_s;
	// turn infix to postfix
	string unit;
	cout << expr.size() << endl;
	for (char ch : expr) {
		if (ch >= '0' && ch <= '9') {
			unit.push_back(ch);
		} else {
			if (!unit.empty()) {
				pf.push_back(unit);
				unit.clear();
			}
			if (ch == '(') {
				op_s.push('(');
			} else if (ch == ')') {
				while (op_s.top() != '(') {
					pf.push_back(string().assign(1,op_s.top()));
					op_s.pop();
				}
				op_s.pop();
			} else { // '+','-','*','/'
				while (!op_s.empty() && op_s.top() != '(' && op_pd[ch] <= op_pd[op_s.top()]) {
					pf.push_back(string().assign(1,op_s.top()));
					op_s.pop();
				}
				op_s.push(ch);
			}
		}
	}
	if (!unit.empty()) {
		pf.push_back(unit);
	}
	while (!op_s.empty()) {
		pf.push_back(string().assign(1,op_s.top()));
		op_s.pop();
	}
	// calculate the postfix expression
	stack<int> num_s;
	num_s.push(stoi(pf.front()));
	for (auto i = pf.begin() + 1;i != pf.end();++i) {
		if (i->front() >= '0' && i->front() <= '9') {
			num_s.push(stoi(*i));
		} else {
			int second = num_s.top();
			num_s.pop();
			int first = num_s.top();
			num_s.pop();
			switch (i->front()) {
				case '+':
					num_s.push(first + second);
					break;
				case '-':
					num_s.push(first - second);
					break;
				case '*':
					num_s.push(first*second);
					break;
				default: // '/'
					num_s.push(first/second);
			}
		}
	}
	return num_s.top();
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string expr;
		cin >> expr;
		cout << calculate(expr.substr(0,expr.size()-1)) << endl;
	}
}

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

int p;
string str;

int Term();
int Factor();
int Elem();
int Digit();

int Term() {
  int a = Factor();
  while (str[p] == '+' || str[p] == '-') {
    char c = str[p];
    p++; // read [+-]
    int b = Factor();
    if (c == '+') {
      a = a + b;
    } else {
      a = a - b;
    }
  }
  return a;
}

int Factor() {
  int a = Elem();
  while (str[p] == '*' || str[p] == '/') {
    char c = str[p];
    p++; // read [*/]
    int b = Elem();
    if (c == '*') {
      a = a * b;
    } else {
      a = a / b;
    }
  }
  return a;
}

int Elem() {
  if (str[p] == '(') {
    p++; // read (
    int a = Term();
    p++; // read )
    return a;
  } else {
    int a = 0;
    while (isdigit(str[p])) {
      int b = Digit();
      a = 10 * a + b;
    }
    return a;
  }
}

int Digit() {
  int a = str[p] - '0';
  p++; // read [0-9]
  return a;
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    p = 0;
    cout << Term() << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

typedef string::const_iterator State;

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

// ??°??????????????????????????????????????°????????????
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);
    }
    //??¨????????????
    return -INF;
}

// ?????????????????????????????????????????????????????????????????????
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;
  REP(i,0,N){
    string S;
    cin>>S;
    State state = S.begin();
    cout<<expression(state)<<endl;
  }
  return 0;
}