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,rnum;
stack<char> op,rop;

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 ;
}

void calc2(){
	int a=rnum.top();rnum.pop();
	int b=rnum.top();rnum.pop();
	char o=rop.top();rop.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;
	}
	rnum.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] == ')' ){
			rnum.push(num.top());num.pop();
 			while(!op.empty()&&op.top()!='('){
				rop.push(op.top());op.pop();
				rnum.push(num.top());num.pop();
			}
			while(!rop.empty())
				calc2();
			num.push(rnum.top());rnum.pop();
			//cout << num.top() << endl;
			op.pop();cur++;
		}else{//ひとまず終了　演算記号のチェックも入れる
			//	cout << "come" << endl;
			op.push(S[cur++]);
		}
	}
	//cout << num.top() << endl;//
	//int tmp=num.top();num.pop();
	//cout << num.top() << endl;//
	//num.push(tmp);

	rnum.push(num.top());num.pop();
	while(!op.empty()&&op.top()!='('){
		rop.push(op.top());op.pop();
		rnum.push(num.top());num.pop();
	}
	while(!rop.empty())
		calc2();
	num.push(rnum.top());rnum.pop();
	//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 <string>
#include <iostream>
using namespace std;

/*
  <expr>   ::= <term> [ ('+'|'-') <term> ]*
  <term>   ::= <factor> [ ('*'|'/') <factor> ]*
  <factor> ::= <number> | '(' <expr> ')'
  <number> :== 1?????\????????°???
*/

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int expr(string& s, int& i) {
  int val = term(s, i);
  while (s[i] == '+' || s[i] == '-') {
    char op = s[i];
    i++;
    int val2 = term(s, i);
    if (op == '+')
      val += val2;
    else
      val -= val2;
  }
  return val;
}

int term(string& s, int& i) {
  int val = factor(s, i);
  while (s[i] == '*' || s[i] == '/') {
    char op = s[i];
    i++;
    int val2 = factor(s, i);
    if (op == '*')
      val *= val2;
    else
      val /= val2;
  }
  return val;
}

int factor(string& s, int& i) {
  int val;
  if (s[i] != '(') {
    val = number(s, i);
  } else {
    i++;
    val = expr(s, i);
    i++;
  }
  return val;
}

int number(string& s, int& i) {
  int val = 0;
  while(isdigit(s[i])) {
    val = val*10 + (s[i] - '0');
    i++;
  }
  return val;
}

int main() {
  int n;
  cin >> n;
  for (int j=0; j<n; j++) {
    int i = 0;
    string str;
    cin >> str;
    cout << expr(str, i) << endl;
  }
}

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

/*
Digit := '0' | '1' | ... | '9'
Number := Digit { Digit }
Expression := Term { ('+'|'-') Term }
Term := Factor { ('*'|'/') Factor }
Factor := '(' Expression ')' | Number
*/

string S;
size_t cur=0;

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

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

    return n;
}

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

int expression(){
    int n=term();
    while(cur<S.length() && (S[cur]=='+' || S[cur]=='-')){
        if(S[cur]=='+'){
            cur++;
            n=n+term();
        }else{
            cur++;
            n=n-term();
        }
    }

    return n;
}

int term(){
    int n=factor();
    while(cur<S.length() && (S[cur]=='*' || S[cur]=='/')){
        if(S[cur]=='*'){
            cur++;
            n=n*factor();
        }else{
            cur++;
            n=n/factor();
        }
    }

    return n;
}

int factor(){
    if(S[cur]=='('){
        cur++;
        int n=expression();
        assert(S[cur]==')');
        cur++;

        return n;
    }else{
        return number();
    }
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cur=0;
        cin >> S;
        S.resize(S.length()-1);

        cout << expression() << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
using namespace std;

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

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);

    while(true){
        if(*begin=='*')ret*=factor(++begin);
        else if(*begin=='/')ret/=factor(++begin);
        else break;
    }
    return ret;
}

int expression(State &begin){
    int ret=term(begin);

    while(true){
        if(*begin=='+')ret+=term(++begin);
        else if(*begin=='-')ret-=term(++begin);
        else break;
    }
    return ret;
}

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





int main(){

    int N;
    cin>>N;
    cin.ignore();
    REP(i,N){

        string s;
        getline(cin,s);
        State begin = s.begin();
        cout<<expression(begin)<<endl;

    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<string>
using namespace std;
int pos;
string parse;
/*
class Parsing{
private:
  string parse;
  int pos;
public:

  Parsing(string s){
    parse = s;
    pos = 0;
  }
*/

int fact();
int term();
int expression();

  int fact(){
    if(parse[pos] == '('){
      pos++;
      int p = expression();
      pos++;
      return p;
    }else{
      //int p=0;
      string p; p.clear();
      while('0' <= parse[pos] && parse[pos] <= '9'){
	//p *= 10;
	//p += parse[pos]-'0';
	p += parse[pos];
	pos++;
      }
      //return p;
      return (atoi)(p.c_str());
    }
  }

 int term(){
    int p = fact();
    while(parse[pos] == '*' || parse[pos] == '/'){
      if(parse[pos] == '*'){pos++;p *= term();}
      else {pos++;p /= term();}
    }
    return p;
  }

 int expression(){
    int p = term();
    while(parse[pos] == '+' || parse[pos] == '-'){
      if(parse[pos] == '+'){pos++;p+=term();}
      else {pos++;p-=term();}
    }
    return p;
  } 
 
/*
};
*/







int main(){
  string s;
  int N;
  cin >> N;
  while(N-- > 0){
    pos = 0;
    cin >> s;
    parse = s.substr(0,s.length()-1);
   
    //Parsing par = Parsing(s.substr(0,s.length()-1));
    //cout << par.expression() << endl;
    cout << expression() << endl;
  }
  return 0;
}