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);
						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<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    int N;
    cin >> N;
    for(int pomu = 0; pomu < N; pomu++){
        string s;
        cin >> s;
        s = s.substr(0, s.size() - 1);
        while(1){
            map<char, vector<int>> m;
            for(int i = 0; i < s.size(); i++){
                if(s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/') m[s[i]].push_back(i);
            }
            vector<int> v;
            if(m.find('*') != m.end() || m.find('/') != m.end()){
                for(int pos : m['*']) v.push_back(pos);
                for(int pos : m['/']) v.push_back(pos);
            }else{
                for(int pos : m['+']) v.push_back(pos);
                for(int pos : m['-']) v.push_back(pos);
            }
            if(v.size() == 0) break;
            sort(v.begin(), v.end());
            string t;
            int pos = v[0];
            string num[2];
            int tmp;
            for(int j = pos - 1; 0 <= j; j--){
                if('0' <= s[j] && s[j] <= '9'){
                    num[0] += s[j];
                }else{
                    for(int k = 0; k <= j; k++){
                        t += s[k];
                    }
                    break;
                }
            }
            for(int j = pos + 1; j <= s.size(); j++){
                if('0' <= s[j] && s[j] <= '9'){
                    num[1] += s[j];
                }else{
                    tmp = j;
                    break;
                }
            }
            int add;
            switch(s[pos]){
                case '+':
                    add = stoi(num[0]) + stoi(num[1]);
                    break;
                case '-':
                    add = stoi(num[0]) - stoi(num[1]);
                    break;
                case '*':
                    add = stoi(num[0]) * stoi(num[1]);
                    break;
                case '/':
                    add = stoi(num[0]) / stoi(num[1]);
                    break;
            }
            t += to_string(add);
            for(int j = tmp; j < s.size(); j++) t += s[j];
            s = t;
        }
        cout << s << endl;
    }
    return 0;
}

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

int op_priority(char a) {
	if(a == '+' || a == '-')
		return 0;
	if(a == '/')
		return 1;
	if(a == '*')
		return 2;
	return -1;
}

void clac_once(stack<long long> & num_stack, stack<char> & op_stack) {
	long long a, b;
	long long c;
	char op;

	b = num_stack.top();
	num_stack.pop();
	a = num_stack.top();
	num_stack.pop();
	op = op_stack.top();
	op_stack.pop();

	switch(op) {
		case '+' :
			c = a + b;
			break;
		case '-':
			c = a - b;
			break;
		case '*':
			c = a * b;
			break;
		case '/':
			c = a / b;
	}

	num_stack.push(c);
}

long long clac(string str) {
	stack<long long> num_stack;
	stack<char> op_stack;

	for(int i = 0; i < str.size();) {
		if(str[i] == '(') {
			int start = ++i;
			int count = 1;

			while(count) {
				if(str[i] == ')')
					count--;
				else if(str[i] == '(')
					count++;
				i++;
			}

			num_stack.push(clac(string(str.begin() + start, str.begin() + i)));
		}
		else if(str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/' || str[i] == '=' || str[i] == ')') {
			while(!op_stack.empty() && op_priority(op_stack.top()) >= op_priority(str[i])) {
				clac_once(num_stack, op_stack);
			}
			op_stack.push(str[i]);
			i++;
		}
		else if('0' <= str[i] && str[i] <= '9') {
			long long tmp = 0;
			while('0' <= str[i] && str[i] <= '9') {
				tmp *= 10;
				tmp += str[i] - '0';
				i++;
			}
			num_stack.push(tmp);
		}
	}

	if(op_stack.size() != 1)
		exit(1);

	return num_stack.top();
}

int main() {
	int n;

	cin >> n;
	for(int i = 0; i < n; i++) {
		string str;

		cin >> str;
		cout << clac(str) << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cctype>

using namespace std;

char s[111];
int cur,len;

int shiki();

int kazu()
{
  if( s[cur] == '(' ) {
    cur += 1;
    int s = shiki();
    cur += 1;
    return s;
  } else {
    int a = s[cur]-'0';
    cur += 1;
    while( isdigit(s[cur]) ) {
      a *= 10;
      a += s[cur]-'0';
      cur += 1;
    }
    return a;
  }
}          

int kou()
{
  int a = kazu();
  while( s[cur] == '*' || s[cur] == '/' ) {
    char o = s[cur]; cur += 1;
    int b = kazu();
    o=='*'?(a*=b):(a/=b);
  }
  return a;
}

int shiki()
{
  int a = kou();
  while( s[cur] == '+' || s[cur] == '-' ) {
    char o = s[cur]; cur += 1;
    int b = kou();
    if( o == '+' ) a += b;
    else a -= b;
  }
  return a;
}

int parse()
{
  len = 0;
  while( s[len] ) len++;
  len--;
  cur = 0;
  return shiki();
}

int main(void)
{
  int n; scanf("%d",&n);
  while( n-- ) {
    scanf("%s",s);
    printf("%d\n",parse());
  }
  return 0;
}