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 <assert.h>
#include <stack>

char buf[128];
int pos;
#define NOW (buf[pos])

bool isdigit(char c) {
	return ('0' <= c && c <= '9');
}

bool isstrong(char c) {
	return (c=='*'||c=='/');
}
bool isweak(char c) {
	return (c=='+'||c=='-');
}

int digit() {
	if ( !isdigit(NOW) ) {
		fprintf(stderr, "%c: ", NOW);
		assert( isdigit(NOW) );
	}
	int ret = NOW - '0';
	pos++;
	
	return ret;
}
int number() {
	int ret = digit();
	while( isdigit(NOW) ) {
		ret = ret*10 + digit();
	}
	return ret;
}

int main(void) {

	int set;
	scanf("%d", &set);
	
	while(set--) {
		scanf("%s", buf);
		std::stack<char> expr;
		std::stack<int>  num;
		
		expr.push('(');
		
		while(true) {
			if(isdigit(NOW)) {
				num.push( number() );
			} else {
				if ( expr.top() == '(' && (NOW==')'||NOW=='=') ) {
					//対応する括弧が出てきたので、スタック上の括弧を消す
					expr.pop();
					if ( expr.empty() ) {
						break;
					}
				} else if ( expr.top() == '(' ||
				     NOW == '(' ||
					 ( isstrong(NOW)&&isweak(expr.top()) ) ) {
					//強い演算子はスタックに積んでおく。括弧が積んであるなら、無条件に積む
					expr.push(NOW);
					pos++;
				} else {
					//次の演算子は弱いor同じだから、積んでるものを先に計算してしまおう
					char de = expr.top(); expr.pop();

					int b = num.top(); num.pop();
					int a = num.top(); num.pop();
					int ans;
					switch(de) {
						case '+': ans=a+b; break;
						case '-': ans=a-b; break;
						case '*': ans=a*b; break;
						case '/': ans=a/b; break;
					}
					num.push(ans);
				}
			}
			
		}
		
		printf("%d\n", num.top());
	}
	
}

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] == '(') {
		i++;
		val1 = siki(str, i);
		i += 2;
	}
	else {
		 val1 = number(str, i);
	}
	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;
}

C++: #include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
using ll = long long;

string str;
int id;
int expr();
int number(){
  int res = 0;
  for (; isdigit(str[id]); id++) {
    res *= 10;
    res += str[id] - '0';
  }
  return res;
}
int factor(){
  int res = 0;
  if(str[id] == '('){
    id++;
    res = expr();
    if(str[id] == ')') ++id;
    return res;
  }else {
  return number();
}

}
int term(){
  int res = factor();
  while(str[id] == '*' || str[id] == '/') {
    if (str[id] =='*') {
      ++id;
      res *= factor();
    } else {
      ++id;
      res /= factor();
    }
  } 
  return res;
}
int expr(){
  int res = term();
  while (str[id] == '+' || str[id] == '-') {
    if(str[id] == '+'){
      ++id;
      res += term();
    } else{
      ++id;
      res -= term();
    }
  }
  return res;
}
int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    id = 0;
    cin >> str;
    int ans = expr();
    cout << ans << endl;
  }
}

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

using namespace std;

string S;
size_t cur=0;
int n;
void init_S(){
    cur=0;
    
}
char readchar(){
    assert(cur<S.size());
    char ret=S[cur];
    cur+=1;
    return ret;
}
char peek(){
    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 factor();
int term(){
    int sum=factor();
    while(cur<S.size()&&(peek()=='*'||peek()=='/')){
        char op=readchar();
        int b=factor();
        if(op=='*')sum*=b;
        else sum/=b;
    }
    return sum;
}
int b;

int expression(){
    int sum=term();
    while(cur<S.size() && (peek()=='+'||peek()=='-')){
        char op=readchar();
        int b=term();
        if(op=='+')sum+=b;
        else sum-=b;
    }
    return sum;
}
           
int factor(){
    if(peek()!='('){
        return number();
    }
    cur++;
    int n=expression();
    assert(peek()==')');
    cur++;
    return n;
}

int parse(){
    return expression();
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S;
        int a=parse();
        cout<<a<<endl;
        S.clear();
        init_S();
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef string::const_iterator State;
#define rep(i,n) for(int i=0;i<(n);i++)

class Parser{
public:
	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 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 factor(State &begin){
		if(*begin == '('){
			begin++;//'('?????????
			int ret = expression(begin);
			begin++;//')'?????????
		}else{
			return number(begin);
		}
	}
	int number(State &begin){
		int ret = 0;
		while(isdigit(*begin)){
			ret *= 10;
			ret += *begin - '0';
			begin++;
		}
		return ret;
	}
};

int main(void){
	int n; cin >> n;
	rep(i, n){
		Parser ps;
		string s; cin >> s;
		string tmp = s.substr(0, s.size() - 1);
		// cout << tmp << endl;
		State begin = s.begin();
		int ret = ps.expression(begin);
		printf("%d\n", ret);
	}
	return 0;
}