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 <cctype>

using namespace std;

class Parser{
    public:

    string s;
    int i, n;

    Parser(string s): s(s) {}

    int parse(){
        i = 0;
        n = s.length();
        return expr();
    }

    private:

    int expr(){
        int ret = term();
        while(s[i] != '='){
            if(s[i] == '+'){
                i++;
                ret += term();
            }else if(s[i] == '-'){
                i++;
                ret -= term();
            }else{
                break;
            }
        }
        return ret;
    }

    int term(){
        int ret = fac();
        while(i < n){
            if(s[i] == '*'){
                i++;
                ret *= fac();
            }else if(s[i] == '/'){
                i++;
                ret /= fac();
            }else{
                break;
            }
        }
        return ret;
    }

    int fac(){
        if(isdigit(s[i])) return num();
        i++;
        int ret = expr();
        // int ret = num();
        // while(s[i] != ')'){
        //     if(s[i] == '+'){
        //         i++;
        //         ret += num();
        //     }else if(s[i] =='-'){
        //         i++;
        //         ret -= num();
        //     }else{
        //         break;
        //     }
        // }
        i++;
        return ret;
    }

    int num(){
        int ret = s[i] - '0';
        i++;
        while(isdigit(s[i])){
            ret = ret * 10 + (s[i] - '0');
            i++;
        }
        return ret;
    }

};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        Parser p = Parser(s);
        cout << p.parse() << endl;
    }
}

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

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

int main(void){
  int N;
  std::cin >> N;

  while(N--){
    std::string s;
    std::cin>>s;
    State begin = s.begin();
    int ans = expression(begin);
    std::cout << ans << std::endl;
  }
  return 0;
}
 
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 expression(State &begin){
  int num = factor(begin);
  int sum = 0;
  
  for(;;){
    char ch = *begin;
    begin++;
    if(ch == '+'){
      sum += num;
      num = factor(begin);
    } else if(ch == '-'){
      sum += num;
      num = -factor(begin);
    }else if(ch == '*'){
      num *= factor(begin);
    }else if(ch == '/'){
      num /= factor(begin);
    }else{
      begin--;
      break;
    }
  }
  return sum+num;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int64 exp(string&, int32&);
int64 term(string&, int32&);
int64 fact(string&, int32&);
int64 number(string&, int32&);

int64 exp(string& s, int32& p){
	int64 ret = term(s, p);
	while(p < s.size()){
		if(s[p] == '+'){
			p++;
			ret += term(s, p);
		}else if(s[p] == '-'){
			p++;
			ret -= term(s, p);
		}else{
			break;
		}
	}
	return ret;
}

int64 term(string& s, int32& p){
	int64 ret = fact(s, p);
	while(p < s.size()){
		if(s[p] == '*'){
			p++;
			ret *= fact(s, p);
		}else if(s[p] == '/'){
			p++;
			ret /= fact(s, p);
		}else{
			break;
		}
	}
	return ret;
}

int64 fact(string& s, int32& p){
	int64 ret = 0;
	if(s[p] == '('){
		p++;
		ret = exp(s, p);
		p++;
	}else{
		ret = number(s, p);
	}
	return ret;
}

int64 number(string& s, int32& p){
	int64 ret = 0;
	while(isdigit(s[p])){
		ret = ret*10+s[p]-'0';
		p++;
	}
	return ret;
}
int main(void){
	int32 N;
	cin >> N;

	REP(i, N){
		string s;
		int32 p = 0;
		cin >> s;
		cout << exp(s, p) << endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int expr(string& s,int& i);//テ・ツシツ?
//<expr>::=<term>[('+'|'-')<term>]
int term(string& s,int& i);//テゥツ??
//<term>::=<factor> [(テ「ツ??テ「ツ?處テ「ツ??テ「ツ??<factor>]*
int factor (string& s,int& i);//テ・ツ崢?ヲツ閉ー
//<factor>::=<number>|テ「ツ??テ「ツ??expr>テ「ツ??テ「ツ??
int number(string& s,int& i);//テヲツ閉ー
//<number>::=テ」ツ?ェテ」ツつ禿」ツ??

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

int factor(string& s,int& i){
  if(isdigit(s[i])) return number(s,i);

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

int term(string& s,int& i){
  int val1=factor(s,i);
  while(s[i]=='*'||s[i]=='/'){
    char op=s[i];
    i++;
    int val2=factor(s,i);
    if(op=='*'){
      val1 =val1*val2;
    }
    else{
      val1=val1/val2;
    }
  }
  return val1;
}

int expr(string& s,int& i){
  int val1=term(s,i);
  while(s[i]=='+'||s[i]=='-'){
    char op=s[i];
    i++;
    int val2=term(s,i);
    if(op=='+'){
      val1 =val1+val2;
    }
    else{
      val1=val1-val2;
    }
  }
  return val1;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

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

C++: #include <iostream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
	char c[100],*st;
	int n,f,ca1,ca2,d;
	stack<int> as;
	stack<char> bs;
	cin >> n;
	for (n;n>0;n--) {
	cin >> c; st=c;
	while(true) {
		if (st[0]=='=') break;
		f=0; d=0;
		if (st[0]=='-') if (st==c) d=1; else if ((st-1)[0]=='(') d=1;
		if ((st[0]>='0' && st[0]<='9') || d==1) {
			as.push(atoi(st)); f=1; st++;
		    for (st;st[0]>='0' && st[0]<='9';st++);	}
		else { if (st[0]==')') { bs.pop(); f=1;} else bs.push(st[0]); st++;}
		if (bs.empty() || f==0) continue;
		while(true){
			if (bs.empty()) break; else if (bs.top()=='(') break;
            if (bs.top()=='*' || bs.top()=='/') {
				ca2=as.top(); as.pop(); ca1=as.top(); as.pop(); 
				if (bs.top()=='*') ca1=ca1*ca2; else ca1=ca1/ca2;
				as.push(ca1); bs.pop();	}
			else if (st[0]!='*' && st[0]!='/') {
                ca2=as.top(); as.pop(); ca1=as.top(); as.pop(); 
				if (bs.top()=='+') ca1=ca1+ca2; else ca1=ca1-ca2;
				as.push(ca1); bs.pop(); } else break;
		}
	}
		cout << as.top() << endl;
		as.pop();
	}
	return 0;
	}