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 <cctype>
#include <cassert>
using namespace std;

string S;
size_t cur = 0;

bool isdigit(char a){
    if(a =='0' or a=='1' or a=='2' or a=='3' or a=='4' or a=='5' or a=='6' or a=='7' or a=='8' or a=='9'){
        return true;
    }
    else return false;
}

int digit(){
    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 factor();

int term(){
    int a = factor();
    while(cur < S.size() && (S[cur] == '*'|| S[cur] == '/')){
        char op = S[cur];
        cur +=1;
        int b = factor();
        if(op == '*') a *= b;
        else a /= b;
    }
    return a;
}

int expression(){
    int a = term();
    while(S[cur] == '+'|| S[cur] == '-'){
        char op = S[cur];
        cur += 1;
        int b = term();
        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 expression();
int term();
int factor();
int number();

int now;
string s;

int expression(){
  int res=term();
  while(true){
    if(s[now]=='+'){
      now++;
      res+=term();
    }else if(s[now]=='-'){
      now++;
      res-=term();
    }else
      break;
  }
  return res;
}

int term(){
  int res=factor();
  while(true){
    if(s[now]=='(')
      res+=factor();
    else if(s[now]=='*'){
      now++;
      res*=factor();
    }else if(s[now]=='/'){
      now++;
      res/=factor();
    }else break;
  }
  return res;
}

int factor(){
  int res=0;
  if(s[now]=='('){
    now++;
    res=expression();
    now++;
  }else
    return number();
  return res;
}

int number(){
  int res=0;
  while('0'<=s[now] && s[now]<='9'){
    res*=10;
    res+=s[now++]-'0';
  }
  return res;
}


int main(void){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    now=0;
    cout << expression() << endl;
  }
  return 0;
}

C++: #include<string>
#include<cstdlib>
#include<iostream>

using namespace std;

int prior[128];

long long parse(string s)
{
	if(s[0]=='(' && s[s.length()-1]==')'){
		bool f=true;
		for(int i=1,d=1;i<s.length()-1;i++){
			if     (s[i]=='(')	d++;
			else if(s[i]==')')	d--;
			if(d==0){	f=false;	break;	}
		}
		if(f)	return parse(s.substr(1,s.length()-2));
	}

	int divprr=3,divpos=10000000;
	for(int i=s.length()-1,d=0;i>=1;i--){
		if     (s[i]==')')	d--;
		else if(s[i]=='(')	d++;

		else if(d==0 && prior[s[i]]!=0){
			if(divprr>prior[s[i]])
				divprr=prior[s[i]],divpos=i;
		}
	}

	if(divpos==10000000)	return atoll(s.c_str());

	switch(s[divpos]){
		case '+': return parse(s.substr(0,divpos)) + parse(s.substr(divpos+1));
		case '-': return parse(s.substr(0,divpos)) - parse(s.substr(divpos+1));
		case '*': return parse(s.substr(0,divpos)) * parse(s.substr(divpos+1));
		case '/': return parse(s.substr(0,divpos)) / parse(s.substr(divpos+1));
	}

	while(1);
}

int main()
{
	prior['+']=prior['-']=1;
	prior['*']=prior['/']=2;

	int n;	cin>>n;
	while(n--){
		string s;	cin>>s;
		s=s.substr(0,s.length()-1);
		cout<<parse(s)<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cctype>
typedef string::const_iterator State;
class ParseError{};

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


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++;
  }
  else return number(begin);
}

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

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