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<bits/stdc++.h>
using namespace std;

char* p;

int number();
int term();
int expression();
int program();

int main(){
	int n;	cin>>n;
	char x[100];
	for(int i=0;i<n;i++){
		scanf("%s",x);
		p=x;
		cout<<expression()<<endl;
	}

	return 0;
}

int program(){
	int num;
	if(*p=='('){
		p++;
		num=expression();
		p++;
	}else num=number();

	return num;
}

int number(){
	int num=0;
	while('0'<=*p &&*p<='9'){
		num*=10;	num+=(*p-'0');
		p++;
	}

	return num;
}

int expression(){
	int num=term();
	while(1){
		if(*p=='+'){
			p++;
			num+=term();
		}else if(*p=='-'){
			p++;
			num-=term();
		}else break;
	}

	return num;
}

int term(){
	int num=program();
	while(1){
		if(*p=='*'){
			p++;
			num*=program();
		}else if(*p=='/'){
			p++;
			num/=program();
		}else break;
	}

	return num;
}

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

vector<string> split(string in)
{
	vector<string> spl;
	int pos = 0;
	if (in[pos] == '-') 
	{
		pos++;
		while (pos < in.size()) {
			if (isdigit(in[pos])) {
				pos++;
			}
			else {
				break;
			}
		}
		spl.push_back(in.substr(0, pos));
		in.erase(0, pos);
		pos = 0;
	}
	while ( pos < in.size())
	{
		if (!isdigit(in[pos]))
		{
			if (pos != 0)
			{
				spl.push_back(in.substr(0, pos));
				in.erase(0, pos);
				pos = 0;
			}
			else
			{
				if (in[0] == '(')
				{
					int cnt = 1;
					int r_pos = 1;
					for (r_pos = 1; r_pos < in.size(); r_pos++)
					{
						if (in[r_pos] == '(')
							cnt++;
						if (in[r_pos] == ')')
							cnt--;
						if (cnt == 0)
							break;
					}
					spl.push_back(in.substr(pos + 1, r_pos - 0 - 1));
					in.erase(0, r_pos + 1);
					pos = 0;
					continue;
				}
				else if (in[0] == '+' || in[0] == '-' || in[0] == '*' || in[0] == '/')
				{
					spl.push_back(in.substr(0, 1));
					in.erase(0, 1);
					pos = 0;
				}
			}
		}
		else {
			pos++;
		}
	}
	if (in.size() != 0) spl.push_back(in);
	return spl;
}
int cal(string &in_str) {
	auto in = split(in_str);
	while (in.size() != 1) {
		auto pos = in.begin();
		while (pos != in.end()) 
		{
			if (*pos == "*") {
				pos--;
				*pos = to_string(cal(*pos)*cal(*(pos + 2)));
				in.erase(pos+1 , pos + 3);
			}
			else if (*pos == "/") {
				pos--;
				*pos = to_string(cal(*pos)/cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if (pos != in.end()) pos++;
		}
		pos = in.begin();
		while (pos != in.end()) {
			if (*pos == "+") {
				pos--;
				*pos = to_string(cal(*pos)+cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			else if (*pos == "-") {
				pos--;
				*pos = to_string(cal(*pos) - cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if(pos != in.end()) pos++;
		}
	}
	return(stoi(in[0]));
}
int main()
{
	string input;
	int n;
	cin >> n;
	while (n--) {
		cin >> input;
		input.erase(input.end() - 1);
		cout << cal(input) << endl;
	}
	return 0;
}

C++: 
// 再帰的下向き構文解析

#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

int expression(void);

string str;
int pos;

int factor(void){

  int num = 0;
  if( isdigit( str[pos] ) ){ // '0' <= str[pos] && str[pos] <= '9' 
    while( isdigit( str[pos] ) ){
      num *= 10;
      num += str[pos] - '0';
      pos++;
    }
    return num;
  }else if( str[pos] == '(' ){
    pos++;
    int res = expression();
    pos++; // ')' の分
    return res;
  }

}

int term(void){

  int res = factor();
  while(1){

    if( str[pos] == '*' ){
      pos++;
      res *= factor();
    }else if( str[pos] == '/' ){
      pos++;
      res /= factor();
    }else break;

  }
  return res;
}

int expression(void){

  int res = term();
  while(1){

    if( str[pos] == '+' ){
      pos++;
      res += term();
    }else if( str[pos] == '-' ){
      pos++;
    res -= term();
    }else break;

  }
  return res;
}

int main(void){

  int dn;
  cin >> dn;

  while(dn--){
    pos = 0;
    cin >> str;
    cout << expression() << endl;
  }
  return 0;
}

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

using namespace std;

int r;
int i;
int sd(char *s, int m){
    int n = 0, d = 0;
    for(;s[i] != '\0';){
        switch(s[i]){
        case '=':
            return n;
        case '+':
            if(m == 1)
                return n;
            i++;
            return n + sd(s, 2);
        case '-':
            if(m == 1)
                return n;
            i++;
            return n - sd(s, 2);
        case '*':
            i++;
            return n * sd(s, 1);
        case '/':
            i++;
            return n / sd(s, 1);
        case '(':
            i++;
            return sd(s, 0);
        case ')':
            i++;
            return n;
        default:
            n = n * 10 + s[i] - '0';
            i++;
            break;
        }
    }
}

int main(void)
{
    int N;

    char str[1024];

    cin >> N;

    for(int k = 0; k < N; k++){
        r = 0;
        i = 0;
        cin >> str;
        printf("%d\n", sd(str, 0));
    }
}