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 <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


string s;



int calc(int b,int e){
	vector<int> v;
	vector<char> ope;
	for(int i=b; i<=e; i++){
		if(s[i]=='('){
			int o=1,c=0;
			for(int j=i+1; j<=e; j++){
				if(s[j]=='(')o++;
				if(s[j]==')'){
					c++;
					if(o==c){
						int a=calc(i+1,j+1);
						v.pb(a);
						i=j;
						break;
					}
				}
			}
		}
		else if(s[i]>='0'&&s[i]<='9'){
			for(int j=i+1; j<=e; j++){
				if(s[j]<'0'||s[j]>'9'){
					string t=s.substr(i,j);
					v.pb(atoi(t.c_str()));
					i=j-1;
					break;
				}
			}
		}
		else{
			ope.pb(s[i]);
		}
	}
	for(int i=0; i<ope.size(); i++){
		if(ope[i]=='*'){
			v[i+1]=v[i]*v[i+1];
			v[i]=0;
			ope[i]=(i==0?'+':ope[i-1]);
		}
		if(ope[i]=='/'){
			v[i+1]=v[i]/v[i+1];
			v[i]=0;
			ope[i]=(i==0?'+':ope[i-1]);
		}
	}
	for(int i=0; i<ope.size()-1; i++){
		if(ope[i]=='+'){
			v[0]+=v[i+1];
		}
		if(ope[i]=='-'){
			v[0]-=v[i+1];
		}
	}
	return v[0];
}


int main(){
	int n;
	cin>>n;
	rep(i,n){
		cin>>s;
		cout<<calc(0,s.size()-1)<<endl;
	}
}

C++: #include <iostream>

int main()
{
std::cout << endl;
return 0;
}

C++: #include<iostream>
#include<cassert>
#include <string>
#include <cctype>

using namespace std;

#if 0
所用時間:

感想:

#endif

string S;
size_t cur;

int expression();
int factor();

char readchar(){
    assert(cur < S.size());
    char ret =  S[cur];
    cur += 1;
    return ret;
} 

char peek(){
    // assert(cur < S.size());
    return S[cur];
}

int digit(){
    // assert(isdigit(peek()));
    int n = readchar() - '0';
    return n;
}

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

int term(){
    int a = factor();
    while(cur < S.size() && (peek()=='*' || peek()=='/')){
        char op = readchar();
        int b = factor();
        if(op=='*') a*= b;
        else a /= b;
        cout << "calc: " << a << " " << op << " " << b << endl;
    }
    return a;
}

int factor(){
    if (peek() == '('){
        cur += 1;
        int n = expression();
        assert(peek() == ')');
        cur += 1;
        return n;
        }
    else return number();
}

int expression(){
    int a = term();
    while(cur < S.size() && (peek()=='+' || peek()=='-')){
        char op = readchar();
        int b = term();
        cout << "calc: " << a << " " << op << " " << b << endl;
        if(op == '+'){
            a += b;
        }else{
            a -= b;
            }
    }
    return a;
}


int parse(){
    return expression();
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> S;
        cur = 0;
        S.resize(S.size()-1); // 最後の=を無視
        int a = parse();
        cout << a << endl;
    }
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

string S = "3*(12+3)";
size_t cur = 0;

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++;
  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 parse() {
  cur = 0;
  return expression();
}

int main (int argc, char const* argv[]) {
  int n; cin>>n;
  rep(i,n) {
    cin>>S;
    S.erase(S.size()-1);
    //cout<<S<<endl;
    cout<<parse()<<endl;
  }
  return 0;
}

C++: n=int(input())
for i in range(n):
    print(input())

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

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

int factor(State &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 factor(State &begin) {
  if (*begin == '(') {
    begin++;
    int ret = expression(begin);
    begin++;
    return ret;
  } else {
    return number(begin);
  }
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    State begin = s.begin();
    cout << expression(begin) << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)
#define big (long long int)(10e9 + 7)

int siki(string &str, int &i);
int kou(string &str, int &i);
int insu(string &str, int &i);
int number(string &str, int &i);

int main(void) {
	int num = 0;
	cin >> num;
	rep(0, num) {
		string str;
		int x = 0;
		cin >> str;
		cout << siki(str, x);
	}
}

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

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

int insu(string &str, int &i) {
	int val1 = 0;

	if(str[i] != '(')val1 = number(str, i);
	if(str[i] == '(') {
		i++;
		val1 += siki(str, i);
		i += 1;
	}

	
	
	return val1;
}

int number(string &str, int &i) {
	int val1 = 0;
	if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			 val1 = (int)str[i] - (int)'0';
		i++;
		if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			val1 = val1 * 10;
			val1 += number(str, i);
		}
	}
	return val1;
}