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>

using namespace std;

string mozi
;
int koko
;
// mae ni tukutta raiburari *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
int koubunnkaiseki();
int koubunnkaiseki2();
int koubunnkaiseki3();

int koubunnkaiseki3()
{
  int atai;
  if( mozi[koko] == '(' ) 
    {
      koko = koko + 1;
      atai = koubunnkaiseki();
      koko = koko + 1;
    }
  else
    {
      atai = 0;
      while( koko < mozi.size() && '0' <= mozi[koko] && mozi[koko] <= '9' )
	{
	  atai = atai * 10;
	  atai = atai + ( mozi[koko] - '0' );
	  koko = koko + 1;
	}
    }
  return atai;
}

int koubunnkaiseki2()
{
  int atai = koubunnkaiseki3();
  for(;mozi[koko]=='*'||mozi[koko]=='/';)
    {
      if( mozi[koko] == '*' )
	{
	  koko = koko + 1;
	  atai = atai * koubunnkaiseki3();
	}
      else
	{
	  koko = koko + 1;
	  atai = atai / koubunnkaiseki3();
	}
    }
  return atai;
}

int koubunnkaiseki()
{
  int atai = koubunnkaiseki2();
  for(;mozi[koko]=='+'||mozi[koko]=='-';)
    {
      if( mozi[koko] == '+' ) 
	{
	  koko = koko + 1;
	  atai = atai + koubunnkaiseki2();
	}
      else 
	{
	  koko = koko + 1;
	  atai = atai - koubunnkaiseki2();
	}
    }
  return atai;
}

int main(int argc,char *argv) 
{
  int dataset;
  cin >> dataset;
  for(int kaisuu=0;kaisuu<dataset;kaisuu++)
    {
      cin >> mozi;
      koko = 0;
      cout << koubunnkaiseki() << endl;
    }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
using namespace std;
typedef string::const_iterator State;
class ParseError {};

int term(State &begin);
int expression(State &begin);
int factor(State &begin);
int number(State &begin);

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 = number(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++;
        return ret;
    }else{
        return number(begin);
    }
}

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

int main(){
    int N;
    cin >> N;
    cin.ignore();
    for(int i = 0; i < N; i++){
        string s;
        getline(cin, s);
        cout << s << endl;
        State begin = s.begin();
        int ans = expression(begin);
        cout << ans <<endl;
    }
}

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

using namespace std;

string input;
int pos;

int fact();
int term();
int expr();

int fact() {
	int result = 0;
	if (input[pos] == '(') {
		pos++;
		result = expr();
		pos++;
	} else {
		while (isdigit(input[pos])) {
			result = result * 10 + input[pos] - '0';
			pos++;
		}
	}
//	cout << "fact: " << result << endl;
	return result;
}

int term() {
	int result = fact();
	while (input[pos] == '*' || input[pos] == '/') {
		if (input[pos] == '*') {
			pos++;
			result *= fact();
		} else {
			pos++;
			result /= fact();
		}
	}
//	cout << "term: " << result << endl;
	return result;
}

int expr() {
	int result = term();
	while (input[pos] == '+' || input[pos] == '-') {
		if (input[pos] == '+') {
			pos++;
			result += term();
		} else {
			pos++;
			result -= term();
		}
	}
//	cout << "expr: " << result << endl;
	return result;
}

int main() {
	int n; cin >> n;
	while (n--) {
		cin >> input;
		pos = 0;
		cout << expr() << endl;
	}
	return 0;
}

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

/*
   <??????????????????> ::= <??????????????????> (+ or -) <??????????????????> (+ or -) ...
   <??????????????????> ::= <??°> (* or /) <??°> (* or /) ...
   <??°>           ::= ...
   */


int expression(State &begin);
int term(State &begin);
int number(State &begin);
int factor(State &begin);

int factor(State &begin)
{ 
  if (*begin == '(')
  {
    begin++;
    int ret = expression(begin);
    begin++;
    return ret;
  }
  else
  {
    return number(begin);
  }
}


int main(void) {
  int N;
  cin >> N;
  cin.ignore();
  for(int i = 0; i < N; i++)
  {
    string s;
    getline(cin, s);
    
    State begin = s.begin();
    int ans = expression(begin);
    cout << ans << endl;
  }

  return 0;
}
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 number(State &begin) {
  int ret = 0;
  while(isdigit(*begin)) {
    ret *=10;
    ret += *begin - '0';
    begin++;
  }

  return ret;

}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem0109 : Smart Calculator **/
string s; int pos;
int factor();

int number()
{
	int ret=0;
	while (isdigit(s[pos])) {
		ret *= 10;
		ret += s[pos++]-'0';
	}
	return ret;
}

int term()
{
	int ret = number();
	
	for(;;) {
		if (s[pos] == '*') {
			pos++;
			ret *= factor();
		} else if (s[pos] == '/') {
			pos++;
			ret /= factor();
		} else {
			break;
		}
	}
	
	return ret;
}

int expression()
{
	int ret=term();
	
	for (;;) {
		if (s[pos] == '+') {
			pos++;
			ret += term();
		} else if (s[pos] == '-') {
			pos++;
			ret -= term();
		} else {
			break;
		}
	}
	
	return ret;
}

int factor()
{
	int ret;
	
	if (s[pos]=='(') {
		pos++;
		ret = expression();
		pos++;
	} else {
		ret = number();
	}
	return ret;
}

int main()
{
	int N; cin>>N;
	rep(i, N) {
		cin>>s;
		pos=0;
		cout << expression() << endl;
	}
}