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>
using namespace std;

int exp();
int term();
int factor();
string str;
int p;
int factor(){
  int val=0;
  while(str[p]>='0' && str[p]<='9'){ 
    val*=10;
    val+=str[p]-'0';
    p++;
  }
  
  if(str[p]=='('){
    p++;
    val=exp();
  }
  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 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 main(){
  int n;
  
  cin>>n;
  for(int i=0;i<n;i++){
    p=0;
    cin>>str;
    cout<<exp()<<endl;
  }
  return 0;
}

C++: 
#include <string>
#include <cctype>
#include<iostream>
#include<map>
#include<sstream>
using namespace std;
istream* input;
int no_of_errors;
enum Token_value {
  END,NUMBER,PLUS='+',MINUS='-',MUL='*',DIV='/',
  PRINT=';',ASSIGN='=',LP='(',RP=')'
};
Token_value curr_tok = PRINT;
int number_value;
string string_value;
Token_value get_token()
{
  char ch;
  do {
    if(!input->get(ch)) return curr_tok = END;
  } while (ch!='\n' && isspace(ch));
 
  switch (ch) {
  case ';':
  case '\n':
    return curr_tok=PRINT;
  case '*':
  case '/':
  case '+':
  case '-':
  case '(':
  case ')':
  case '=':
return curr_tok=Token_value(ch);
  case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
    input->putback(ch);
    *input >> number_value;
    return curr_tok=NUMBER;
  }
}
int expr(bool);
int prim(bool get)
{
  if (get) get_token();
  switch (curr_tok) {
  case NUMBER:
    { int v = number_value;
      get_token();
      return v;
    }
  case MINUS:
    return -prim(true);
  case LP:
    { int e = expr(true);
      get_token();
      return e;
    }
  }
}
int term(bool get)
{
  int left = prim(get);
  for (;;)
    switch (curr_tok) {
    case MUL:
      left *= prim(true);
      break;
    case DIV:
      if (int d = prim(true)) {
left /= d;
break;
      }
    default:
      return left;
    }
}
int expr(bool get)
{
  int left = term(get);
  for (;;)
    switch (curr_tok) {
    case PLUS:
      left += term(true);
      break;
    case MINUS:
      left -= term(true);
      break;
    default:
      return left;
    }
}
int main()
{
  int n;
  input = &cin;
  cin>>n;
  while(n--){
    while (*input) {
      get_token();
      if (curr_tok == END) break;
      if (curr_tok == PRINT) continue;
      cout << expr(false) << '\n';
    }
  }
  return no_of_errors;
}

C++: #include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


string toRPN(string s){
	stack<char> ope;
	string ret;
	
	rep(i,s.size()){
		if( isdigit(s[i]) ) ret+=s[i];
		
		else{
			switch(s[i]){
				case '(' :
					ope.push(s[i]);
					break;
				case ')' :
					while(ope.top()!='('){
						ret+=ope.top();
						ope.pop();
					}
					ope.pop();
					break;
				case '*' :
				case '/' :
					while( !ope.empty() && (ope.top()=='*' || ope.top()=='/') ){
						ret+=ope.top();
						ope.pop();
					}
					ope.push(s[i]);
					break;
				case '+' :
				case '-' :
					while( !ope.empty() && (ope.top()=='*' || ope.top()=='/' || ope.top()=='+' || ope.top()=='-') ){
						ret+=ope.top();
						ope.pop();
					}
					ope.push(s[i]);
					break;
				default :
					return "invalid";
					break;
			}

		}
	}
	while(ope.size()){
		ret+=ope.top();
		ope.pop();
	}
	
	return ret;
}

string solveRPN(string s){
	stack<int> stk;
	
	
	for(int i=0;i<s.size();i++){
		if( isdigit(s[i]) )stk.push( s[i]-'0'  );
		else{
			int b=stk.top(); stk.pop();
			int a=stk.top(); stk.pop();
			
			if(s[i]=='+')stk.push(a+b);
			if(s[i]=='-')stk.push(a-b);
			if(s[i]=='*')stk.push(a*b);
			if(s[i]=='/')stk.push(a/b);
		}
	}
	
	stringstream ret;
	ret<<stk.top();
	
	return ret.str();
}


int main(){
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		
		s.erase(s.size()-1);
		
		s=toRPN(s);
		s=solveRPN(s);
		
		cout<<s<<endl;
	}
	
	return 0;
}

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


typedef string::const_iterator State;


int expression(State &begin);


int number(State &begin)
{
	int ret = 0;
	
	for(; isdigit(*begin); begin++) {
		ret = ret * 10 + *begin - '0';
	}

	return ret;
}

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

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

	while(true) {
		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);

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

	return ret;
}


int main()
{
	int N;
	cin >> N;
	cin.ignore();
		
	for (int i = 0; i < N; i++) {
		string s;
		getline(cin, s);

		State begin = s.begin();
		cout << expression(begin) << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<cctype>
#include<string>
using namespace std;
typedef string::const_iterator State;

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

int main(void){
  int N;
  cin >> N;
  cin.ignore();

  for(int i=0;i<N;i++){
    string s;
    getline(cin,s);

    State begin=s.begin();
    int ans=expression(begin);
    cout << ans << endl;
  }
  return 0;
}

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 term(State &begin){
  int ret=number(begin);

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

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

int number(State &begin){
  int ret=0;

  while(isdigit(*begin)){
    ret*=10;
    ret+=*begin-'0';
    begin++;
  }
  return ret;
}