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 <cassert>
#include <cctype>
using namespace std;
string S;
size_t cur = 0;
int term();
int factor();
int expression();
int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0'; 
	cur = cur + 1;
	return n;
}
int number(){
	int n = digit();
	while(cur<S.size() && isdigit(S[cur]))
		n = n*10 + digit();
	return n;
}
int expression(){
	int a =term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')){
		char op = S[cur++];
		int b = term();
		if (op == '+') a += b;
		else a -= b;
	}
	return a;
}
int term(){
	int a =factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = factor();
		if (op == '*') a *= b; else a /= b;
	}
	return a;
}
int factor(){
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur +=1;
	return n;
}
int main() {

	int N;
	cin >> N;
	for (int i=0; i<N;++i){
		cur = 0;
		cin >> S;
		S.resize(S.size()-1);
		cout << expression() << endl;
	}
	return 0;

}

C++: #include <iostream>
#include <string>
using namespace std;
int exp();
int term();
int factor();
int number();
int digit();
int p=0;
string str;
int cnt=0;
int ret;
int main(){
  int n,re;
  cin >> n;
  while(n){
    p=0;
    cin >> str;
    re=exp();
    cout << re << endl;
    n--;
  }
  return 0;
}
int exp(){
  int val=term();
  while(str[p]=='+'||str[p]=='-'){
    if(str[p]=='+'){
      p++;
      val+=term();
    }else if(str[p]=='-'){
      p++;
      val-=term();
    }
  }
  return val;
}
int term(){
  int val=factor();
  while(str[p]=='*'||str[p]=='/'){
    if(str[p]=='*'){
      p++;
      val*=factor();
    }else if(str[p]=='/'){
      p++;
      val/=factor();
    }
  }
  return val;
}
int factor(){
  int val=number();
  if(str[p]=='('){
    p++;
    val=exp();
  }else if(str[p]==')'){
    p++;
  }
  return val;
}
int number(){
  int val=digit();
  ret=0;
  cnt=0;
  return val;
}
int digit(){
    if(str[p]=='0'||str[p]=='1'||str[p]=='2'||str[p]=='3'||str[p]=='4'||str[p]=='5'||str[p]=='6'||str[p]=='7'||str[p]=='8'||str[p]=='9'){
    if(cnt==0){
      ret=str[p]-'0';
      cnt=1;
    }
    p++;
    if(str[p]=='0'||str[p]=='1'||str[p]=='2'||str[p]=='3'||str[p]=='4'||str[p]=='5'||str[p]=='6'||str[p]=='7'||str[p]=='8'||str[p]=='9'){
      ret=ret*10+(str[p]-'0');
      digit();
    }
    return ret;
  }
}

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

using namespace std;
typedef pair<const char *, int > parsed;

parsed expr(const char *);
parsed term(const char *);
parsed fact(const char *);

parsed expr(const char *p){
	parsed r = term(p);
	while( *(r.first)=='+' || *(r.first)=='-' ){
		const char *op = r.first;
		parsed l = term(op+1);

		if( *op=='+' ){
			r.first = l.first;
			r.second = r.second + l.second;
		}else{
			r.first = l.first;
			r.second = r.second - l.second;
		}
	}
	return r;
}
parsed term(const char *p){
	parsed r = fact(p);
	while( *(r.first)=='*' || *(r.first)=='/' ){
		const char *op = r.first;
		parsed l = fact(op+1);

		if( *op=='*' ){
			r.first = l.first;
			r.second = r.second * l.second;
		}else{
			r.first = l.first;
			r.second = (int)floor(r.second / (double)l.second);
		}
	}
	return r;
}
parsed fact(const char *p){
	if( *p=='(' ){
		// new expression
		parsed tp = expr(p+1);
		return parsed(tp.first+1, tp.second);
	}
	if( *p=='-' ){
		// negative fact
		parsed tp = fact(p+1);
		tp.second *= -1;
		return tp;
	}
	if( isdigit(*p) ){
		// number
		int num = *p - '0';
		while( isdigit(*(++p)) ){
			num *= 10;
			num += *p - '0';
		}
		return parsed(p,num);
	}else assert(0); return parsed(NULL,0);
}
int main(void){
	int n;

	cin>>n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		cout << expr(s.c_str()).second << '\n';
	}
	return 0;
}

C++: #include<iostream>
#include<sstream>

using namespace std;

string str;

bool isNum(string s){
  for(int i = 1; i < s.length(); i++)
    if(s[i] < '0' || s[i] > '9') return false;

  return true;
}

int solve(string s){

  //  cout << s << endl;
  if(isNum(s)){
    stringstream ss(s);
    int out;
    ss >> out;
    return out;
  }

  int pos = -1;

  for(int i = 0; i < s.length(); i++)
    if(s[i] == '+' || s[i] == '-' || s[i] == '('){
      pos = i;
      break;
    }

  if(pos == -1){
    int now = 0;
    string a,b;
    a = b = "";

    for(int i = 0; i < s.length(); i++){
      if(s[i] == '*' || s[i] == '/'){
	now = i;
	break;
      }
      a += s[i];

    }

    for(int i = now+1; i < s.length(); i++)
      b+=s[i];

    if(s[now] == '+') return solve(a)+solve(b);
    if(s[now] == '-') return solve(a)-solve(b);
    if(s[now] == '*') return solve(a)*solve(b);
    if(s[now] == '/') return solve(a)/solve(b);

  }else{

    string a,b;
    a = b = "";

    for(int i = 0; i < pos; i++)
      a += s[i];
    for(int i = pos+1; i < s.length(); i++)
      b += s[i];

    if(s[pos] == '+') return solve(a)+solve(b);
    else if(s[pos] == '-') return solve(a)-solve(b);
    else if(s[pos] == '('){

      if(pos == 0){

	int par = 1;
	a = b = "";
	int now;

	for(int i = 1; i < s.length(); i++){
	  if(s[i] == '(') par++;
	  if(s[i] == ')') par--;
	  a+=s[i];
	  if(par == 0){
	    now = i+1;
	    break;
	  }
	}

	if(now == s.length()){
	  for(int i = 1; i < s.length()-1; i++)
	    b += s[i];

	  return solve(b);
	}

	for(int i = now+1; i < s.length(); i++)
	  b+=s[i];

	if(s[now] == '+') return solve(a)+solve(b);
	if(s[now] == '-') return solve(a)-solve(b);
	if(s[now] == '*') return solve(a)*solve(b);
	if(s[now] == '/') return solve(a)/solve(b);
	


      }else{
	a = b = "";

	for(int i = 0; i < pos-1; i++)
	  a+=s[i];

	for(int i = pos; i < s.length(); i++)
	  b+=s[i];

	if(s[pos-1] == '+') return solve(a)+solve(b);
	if(s[pos-1] == '-') return solve(a)-solve(b);
	if(s[pos-1] == '*') return solve(a)*solve(b);
	if(s[pos-1] == '/') return solve(a)/solve(b);
       
      }
    }
  }

}

string make(string s){
  string out = "";

  for(int i = 0; i < s.length()-1; i++)
    out += s[i];

  return out;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> str;
    str = make(str);
    cout << solve(str) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
string s;
int a;
int num(){
	int out=0;
	while(isdigit(s[a])){out*=10;out+=s[a]-'0';a++;}
	return out;
}
int func();
int func2(){
	int out=num();
	while(a!=s.size()){
		if(s[a]=='*'){
			a++;
			if(s[a]=='('){a++;out*=func();}
			else out*=num();
		}else if(s[a]=='/'){
			a++;
			if(s[a]=='('){a++;out/=func();}
			else out/=num();
		}else return out;
	}
}
int func(){
	int out=num();
	while(a!=s.size()){
		//cout<<a<<" "<<out<<endl;
		if(s[a]=='=')return out;
		if(s[a]==')')return out;
		if(s[a]=='+'){a++;out+=func2();}
		else if(s[a]=='-'){a++;out-=func2();}
	}
	return out;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		a=0;
		cin>>s;
		s="0+"+s;
		cout<<func()<<endl;
	}
}