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 <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int exp();
int term();
int fact();
string s;
int id;

int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    id = 0;
    cout << exp() << endl;
  }
}


int exp(){
  int res = term();
  while(1){
    char c = s[id];
    id++;
    if(c == '+') res += term();
    else if(c == '-') res -= term();
    else break;
  }
  return res;
}

int term(){
  int res = fact();
  while(1){
    char c = s[id];
    id++;
    if(c == '*') res *= fact();
    else if(c=='/') res /= fact();
    else break;
  }
  id--;
  return res;
}

int fact(){
  char c = s[id];
  id++;
  if(c == '(') return exp();
  if(c == '+') return fact();
  if(c == '-') return -fact();

  int res = c - '0';
  while(1){
    c = s[id];
    id++;
    if('0' <= c && c <= '9'){
      res *= 10;
      res += c - '0';
    }
    else break;
  }
  id--;
  return res;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

string S;
size_t cur=0;
int parse();

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

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

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

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 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 main() {
    while(cin>>S){
	cur=0;
	cout<<expression()<<endl;
    }
}

C++: #include <string>
#include<cctype>
#include<cstdio>
using namespace std;
typedef string::const_iterator State;
class ParseError {};

int expression(State &begin);

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

  while(isdigit(*begin)){
    ret*=10;
    ret+=*begin-'0';
    begin++;
  }
  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 = factor(begin);

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

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

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    char s[105];
    scanf("%s",s);
    string S(s);

    State begin=S.begin();
    int ans=expression(begin);
    printf("%d\n",ans);
  }
  return 0;
}

C++: #include <iostream>
#include <cctype>
using namespace std;
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){
  if(isdigit(s[i]))return number(s,i);


  i++;
  int ret = expr(s,i);
  i++;
  return ret;
}

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

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

}

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

typedef std::stringstream sst;

int ToInt(std::string str){
	int i;
	sst ss;
	ss<<str;
	ss>>i;
	return i;
}
std::string ToStr(int i){
	std::string str;
	sst ss;
	ss<<i;
	ss>>str;
	return str;
}

std::string SubStr(std::string str,int x,int y){
	return str.substr(x,y-x+1);
}
int Third(std::string str){
	int fres,Ans;
	while( ( fres=str.find_first_of("+-",1) ) != std::string::npos ){
		int aRes;
		
		if( (aRes=str.find_first_of("+-",fres+2)) == std::string::npos )
			aRes=str.size()-1;
		else --aRes;
		
		if( str[fres] =='+' ){
			Ans=ToInt(SubStr(str,0,fres-1))+ToInt(SubStr(str,fres+1,aRes));
			str.replace(0,SubStr(str,0,aRes).size(),ToStr(Ans).c_str());
		}else{
			Ans=ToInt(SubStr(str,0,fres-1))-ToInt(SubStr(str,fres+1,aRes));
			str.replace(0,SubStr(str,0,aRes).size(),ToStr(Ans).c_str());
		}
	}
	return ToInt(str);
}

int Second(std::string str){
	int fres,Ans;
	while( ( fres=str.find_first_of("*/") ) != std::string::npos ){
		int bRes,aRes;
		if( (bRes=str.find_last_of("+-",fres)) == std::string::npos  || bRes==0 )
			bRes=0;
		else ++bRes;
		
		if( (aRes=str.find_first_of("+-*/",fres+2)) == std::string::npos )
			aRes=str.size()-1;
		else --aRes;
		
		if( str[fres] =='*' ){
			Ans=ToInt(SubStr(str,bRes,fres-1))*ToInt(SubStr(str,fres+1,aRes));
			str.replace(bRes,SubStr(str,bRes,aRes).size(),ToStr(Ans).c_str());
		}else{
			Ans=ToInt(SubStr(str,bRes,fres-1))/ToInt(SubStr(str,fres+1,aRes));
			str.replace(bRes,SubStr(str,bRes,aRes).size(),ToStr(Ans).c_str());
		}
	}
	std::cout<<str<<std::endl;
	Ans=Third(str);
	return Ans;
}

int First(std::string str){
	int fres;
	while( (fres = str.find(")") ) != std::string::npos ){
		int rfres=str.rfind("(",fres);
		std::string Next=SubStr(str,rfres+1,fres-1);
		int cRes=Second(Next);
		str.replace(rfres,Next.size()+2,ToStr(cRes).c_str());
	}
	int lRes = Second(str);
	
	return lRes;
}

int main(){
	int n;
  std::string str;
	std::cin>>n;
	while( n-- ){
		std::cin>>str;
	  std::cout<<First(str)<<std::endl;
	}
}