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

string S;
size_t cur=0;

int term();
int expression();

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 factor() {
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur += 1;
	return n;
}

int term(){
	int sum = factor();
	while(S[cur] == '*' || S[cur] == '/'){
		char op = S[cur];
		cur += 1;
		int b = factor();
		if( op == '*')
			sum*=b;
		else {
			assert(b);
			sum/=b;
		}
	}
	return sum;
}

int expression(){
	int sum = term();
	while(S[cur] == '+' || S[cur] == '-'){
		char op = S[cur];
		cur += 1;
		int b = term();
		if( op == '+')
			sum+=b;
		else 
			sum-=b;
	}
	return sum;
}



int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> S;
		cur=0;
		int r;
		r=expression();
		cout << r << endl;
	}
return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;


int main(){
    int n;
    string s;
    while(cin>>n){
        for(int i=0; i<n; i++){
            cin>>s;
            int j=0;
            
            queue<string> qu;
            stack<string> st;
            
            
            while(j<s.length()){
                //cout<<s[j]<<endl;
                //数値の処理
                if(s[j]>='0'&&s[j]<='9'){
                    string s_temp;
                    
                    while(s[j]>='0'&&s[j]<='9'){
                        s_temp+=s[j];
                        j++;
                    }
                    
                    qu.push(s_temp);
                    
                }
                
                //括弧の処理
                else if(s[j]==')'){
                    while(1){
                        string s_temp;
                        s_temp = st.top();
                        st.pop();
                        if(s_temp=="("){
                            break;
                        }else{
                            qu.push(s_temp);
                        }
                    }
                    j++;
                }
                
                else if(s[j]=='('){
                    string s_temp;
                    s_temp+=s[j];
                    st.push(s_temp);
                    j++;
                }
                
                //演算子の処理
                else if(s[j]=='-'||s[j]=='+'||s[j]=='*'||s[j]=='/'){
                    string s_temp;
                    s_temp+=s[j];
                    if(st.empty()){
                        st.push(s_temp);
                        j++;
                    }else{
                        if(!(s_temp=="*"||s_temp=="/")&&(st.top()=="-"||(st.top()=="+"))){
                            s_temp = st.top();
                            st.pop();
                            qu.push(s_temp);
                        }else{
                            st.push(s_temp);
                            j++;
                        }
                    }
                }
                //=の処理
                else if(s[j]=='='){
                    j++;
                }
                
                
            }
            while(!st.empty()){
                qu.push((st.top()));
                st.pop();
            }
            
            stack<int> num;
            while(!qu.empty()){
                
                //cout<<qu.front()<<endl;
                
                if(qu.front()=="*"){
                    int a,b;
                    a=num.top();
                    num.pop();
                    b=num.top();
                    num.pop();
                    a=a*b;
                    num.push(a);
                }else if(qu.front()=="/"){
                    int a,b;
                    a=num.top();
                    num.pop();
                    b=num.top();
                    num.pop();
                    a=a/b;
                    num.push(a);
                    
                }else if(qu.front()=="-"){
                    int a,b;
                    a=num.top();
                    num.pop();
                    b=num.top();
                    num.pop();
                    a=b-a;
                    num.push(a);
                }else if(qu.front()=="+"){
                    int a,b;
                    a=num.top();
                    num.pop();
                    b=num.top();
                    num.pop();
                    a=a+b;
                    num.push(a);
                }else{
                    stringstream stream;
                    stream<<qu.front();
                    int temp;
                    stream>>temp;
                    num.push(temp);
                }
                qu.pop();
            }
            cout<<num.top();
        }
        
    }
}

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());
		}
	}
	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;
	}
}