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

using namespace std;

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

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

int expression(State &begin){
  //cout <<"expression"<<endl;
  int ret = term(begin);
  while(1){
    if(*begin == '+'){
      begin++;
      ret += term(begin);
    }
    else if(*begin == '-'){
      begin++;
      ret -= term(begin);
    }
    else break;
  }
  return ret;
}

int term(State &begin){
  //cout <<"term"<<endl;
  int ret = factor(begin);
  
  while(1){
    if(*begin == '*'){
      begin++;
      ret *= factor(begin);
    }
    else if(*begin == '/'){
      begin++;
      ret /= factor(begin);
    }
    else break;
  }
  return ret;
}

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

int factor(State &begin){
  //cout <<"factor"<<endl;
  if(*begin == '('){
    begin++;
    int ret = expression(begin);
    begin++; // ')' をスキップ
    return ret;
  }

  if(*begin == '-'){
    begin++;
    return -factor(begin);
  }
  return number(begin);
}

// beginがexpectedを指していたらbeginを一つ進める。
/*void consume(State &begin, char expected) {
  if (*begin == expected) {
    begin++;
  } else {
    cerr << "Expected '" << expected << "' but got '" << *begin << "'"
	 << endl;
    cerr << "Rest string is '";
    while (*begin) {
      cerr << *begin++;
    }
    cerr << "'" << endl;
    throw ParseError();
    }
    }*/

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

C++: #include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int number(State &begin){
    int ret = 0;
    while(isdigit(*begin)){
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    return ret;
}
int term(State &begin){
    int ret = number(begin);
    while(1){
        if(*begin == '*'){
            begin++;
            ret *=  number(begin);
        }else if(*begin == '/'){
            begin++;
            ret /= number(begin);
        }else{
            break;
        }
    }
    return ret;
}
int expression(State &begin){
    int ret = term(begin);
    while(1){
        if(*begin == '+'){
            begin++;
            ret += term(begin);
        }else if(*begin == '-'){
            begin++;
            ret -= term(begin);
        }else{
            break;
        }
    }
    return ret;
}
int main(){
    string s;
    CIN(N);
    REP(a,N){
        cin >> s;
        State w = s.begin();
        COUT(expression(w));
    }
    return 0;
}

C++: #include<iostream>
#define INF (1<<26)
using namespace std;
int n;



int compute(int a,int b,string str){
  int i=a,sum=0,tmp=INF,tmp2=INF,cnt=0;
  while(1){
    sum=0;
    if(str[i]=='('){
      sum=compute(i+1,0,str);
      for(i=a+1;i<(int)str.size();i++){
	if(str[i]==')')cnt--;
	if(str[i]=='(')cnt++;
	if(cnt<0)break;
      }
      i++;
    }else{
      while(1){
	if('0'<=str[i]&&str[i]<='9'){
	  sum*=10;
	  sum+=(str[i]-'0');
	  i++;
	}else{
	  break;
	}
      }
    }
    
    if(b==1){
      sum*=-1;
      b=0;
    }
    if(tmp!=INF){
      sum*=tmp;
      tmp=INF;
    }
    if(tmp2!=INF){
      sum=tmp2/sum;
      tmp2=INF;
    }
    
    if(str[i]=='\0'||str[i]==')')return sum;
    if(str[i]=='+')return sum + compute(i+1,0,str);
    if(str[i]=='-')return sum + compute(i+1,1,str);
    if(str[i]=='*'){
      i++;
      tmp=sum;
    }else if(str[i]=='/'){
      i++;
      tmp2=sum;
    }
  }
      
}


int main(){
  string str;
  cin>>n;
  while(n--){
    cin>>str;
    if(str[str.size()-1]=='=')str=str.substr(0,str.size()-1);
    //cout<<str<<endl;
    cout<<compute(0,0,str)<<endl;
  }
  return 0;
}

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

using namespace std;

typedef string::const_iterator State;

int expr(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 expr(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=expr(begin);
		begin++;
		return ret;
	}else{
		return number(begin);
	}
}

int main(){
	int N;
	cin>>N;
	cin.ignore();
	for(int i=0;i<N;i++){
		string str;
		getline(cin,str);
		State begin=str.begin();
		int ans=expr(begin);
		cout<<ans<<endl;
	}
	return 0;
}