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

C++: #include <cstdio>
#include <cassert>
#include <algorithm>
using namespace std;

char *pt;
int parseAtom();
int parseExpr();
int parseTerm();
int parseAtom() {
  if('0' <= *pt && *pt <= '9') {
    int x = *pt-'0';
    pt++;
    while('0' <= *pt && *pt <= '9') {
      x = x*10 + *pt-'0';
      pt++;
    }
    return x;
  }
  if('(' == *pt) {
    pt++;
    int x = parseExpr();
    assert(*pt == ')');
    pt++;
    return x;
  }
  assert(false);
  return -1;
}
int parseExpr() {
  int x = parseTerm();
  while(*pt == '+' || *pt == '-') {
    if(*pt == '+') {
      pt++;
      x += parseTerm();
    } else {
      pt++;
      x -= parseTerm();
    }
  }
  return x;
}
int parseTerm() {
  int x = parseAtom();
  while(*pt == '*' || *pt == '/') {
    if(*pt == '*') {
      pt++;
      x *= parseAtom();
    } else {
      pt++;
      x /= parseAtom();
    }
  }
  return x;
}

int main() {
  int tc; scanf("%d", &tc);
  for(int tci = 0; tci < tc; tci++) {
    static char expr[200]; scanf(" %s", expr);
    pt = expr;
    int x = parseExpr();
    assert(*pt == '=');
    printf("%d\n", x);
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#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);

    // ここで構文が正しければ 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()
{
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        string str;
        cin >> str;
        int j = 0;
        cout << expr(str, j) << endl;
    }

    return 0;
}

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

int hyoka(string);
int isNum(int);

int main(){
	int n,i;
	string s;
	
	cin>>n;
	for(i=0;i<n;i++){
	 cin>>s;
	 cout<<hyoka(s)<<endl;
	}
		
	return 0;
}


int hyoka(string s){
	long int total=0,work=0;
	long int tmp1,tmp2;
	int oi=0;
	char oc;
	int n;
	string cs;
	
	if(isNum(s[oi])==-1){s="+"+s;}
	
	while(1){
	 oc=s[oi];if(oc=='='){total+=work;break;}
	 
	 if(s[oi+1]!='('){	//??°???????????????
	  tmp1=0;
	  while(1){
	   oi++;
	   tmp2=s[oi];
	   if(tmp2!=-1){tmp1=tmp1*10+tmp2;}else{break;}
	  }
	 }else{	//??????????????°
	  cs="";n=1;oi++;
	  while(1){
	   oi++;
	   switch(s[oi]){
		case '(':n++;break;
		case ')':n--;break;
	   }
	   if(n!=0){cs+=s[oi];}else{break;}
	  }
	  tmp1=hyoka(cs);
	 }
	
	 switch(oc){
	  case '+':total+=work;work=tmp1;break;
	  case '-':total+=work;work=-tmp1;break;
	  case '*':work*=tmp1;break;
	  case '/':work/=tmp1;break;
	 }
	}
	
	return total;
}

int isNum(int c){
	if(49<=c && c<=57){
	 return c-49;
	}
	return -1;
}