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 <cassert>
#include <cctype>

using namespace std;

string str;
int cur = 0;

int expression();
int term();
int factor();

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

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

int expression() {
    int a = factor();
    while (cur < str.size() && (str[cur] == '+' || str[cur] == '-')) {
        if (str[cur] == '+') {
            cur++;
            int b = factor();
            a += b;
        } else if (str[cur] == '-') {
            cur++;
            int b = factor();
            a -= b;
        }
    }
    return a;
}

int term() {
    int a = number();
    while (cur < str.size() && (str[cur] == '*' || str[cur] == '/')) {
        if (str[cur] == '*') {
            cur++;
            int b = factor();
            a *= b;
        } else if (str[cur] == '/') {
            cur++;
            int b = factor();
            a /= b;
        }
        cur++;
    }
    return a;
}

int factor() {
    if (str[cur] != '(') return term();

    cur++;
    int a = expression();
    assert(str[cur] == ')');
    cur++;
    return a;
}

int main() {
    int N = 0;
    cin>>N;
    for (int n = 0; n < N; n++) {
        cin>>str;
        cur = 0;
        cout<<expression()<<endl;
    }
}

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

int exp(string &s, int &i);
int term(string &s, int &i);
int factor(string &s, int &i);
int number(string &s, int &i);

int exp(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 val = exp(s, i);
  i++;
  return val;
}

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

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

C++: #include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


string toRPN(string s){
	stack<char> ope;
	string ret;
	
	rep(i,s.size()){
		if( isdigit(s[i]) ) ret+=s[i];
		
		else{
//			switch(s[i]){
//				case '(' :
//					ope.push(s[i]);
//					break;
//				case ')' :
//					while(ope.top()!='('){
//						ret+=ope.top();
//						ope.pop();
//					}
//					ope.pop();
//					break;
//				case '*' :
//				case '/' :
//					while( !ope.empty() && (ope.top()=='*' || ope.top()=='/') ){
//						ret+=ope.top();
//						ope.pop();
//					}
//					ope.push(s[i]);
//					break;
//				case '+' :
//				case '-' :
//					while( !ope.empty() && (ope.top()=='*' || ope.top()=='/' || ope.top()=='+' || ope.top()=='-') ){
//						ret+=ope.top();
//						ope.pop();
//					}
//					ope.push(s[i]);
//					break;
//				default :
//					return "invalid";
//					break;
//			}
			if(s[i]=='('){
				ope.push(s[i]);
				
			}else if(s[i]==')'){
				while(ope.top()!='('){
					ret+=ope.top();
					ope.pop();
				}
				ope.pop();
				
			}else if( s[i]=='*' || s[i]=='/' ){
				while( !ope.empty() && (ope.top()=='*' || ope.top()=='/') ){
					ret+=ope.top();
					ope.pop();
				}
				ope.push(s[i]);
				
			}else if( s[i]=='+' || s[i]=='-' ){
				while( !ope.empty() && (ope.top()=='*' || ope.top()=='/' || ope.top()=='+' || ope.top()=='-') ){
					ret+=ope.top();
					ope.pop();
				}
				ope.push(s[i]);
				
			}else{
				return "invalid";
			}
		}
	}
	while(ope.size()){
		ret+=ope.top();
		ope.pop();
	}
	
	return ret;
}

string solveRPN(string s){
	stack<int> stk;
	
	
	for(int i=0;i<s.size();i++){
		if( isdigit(s[i]) )stk.push( s[i]-'0'  );
		else{
			int b=stk.top(); stk.pop();
			int a=stk.top(); stk.pop();
			
			if(s[i]=='+')stk.push(a+b);
			if(s[i]=='-')stk.push(a-b);
			if(s[i]=='*')stk.push(a*b);
			if(s[i]=='/')stk.push(a/b);
		}
	}
	
	stringstream ret;
	ret<<stk.top();
	
	return ret.str();
}


int main(){
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		
		s.erase(s.size()-1);
		
		s=toRPN(s);
		s=solveRPN(s);
		
		cout<<s<<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) << endl;
	}
}

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);
	else if(str[i] == '(') {
		i++;
		val1 += siki(str, i);
		i += 1;
	}
	return val1;
}

int number(string &str, int &i) {
	int val1 = 0;
	int val2 = 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') {
			int now = i;
			val2 += number(str, i);
			val1 = val1 * pow(10,i - now);
			val1 += val2;

		}
	}
	return val1;
}