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 <cassert>
#include <string>
#include <cctype>
using namespace std;
 
string S;
size_t cur = 0;
char readchar();
char peek();
int digit();
int number();
int term();
int expression();
int factor();
 
int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        cur = 0;
        cin >> S;
        S.resize(S.size()-1);
        cout << expression() << endl;
    }
    return 0;
}
 
char readchar(){
    assert(cur < S.size());
    char ret = S[cur];
    cur += 1;
    return ret;
}
 
char peek(){
    assert(cur < S.size());
    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 term()
{
    int a = factor();
    while(cur < S.size() && (peek() == '*' || peek() == '/')){
        char op = readchar();
        int b = factor();
        if (op == '*') a *= b; else a /= b;
    }
    return a;
}
 
int expression(){
    int a = term();
    while(cur < S.size() && (peek() == '+' || peek() =='-'))
    {
        char op =readchar();
        int b = term();
        if(op == '+')
        {
            a += b;
        }
        else a -= b;
    }
    return a;
}
int factor() {
    if (peek() != '(') return number();
    cur += 1;
    int n = expression();
    assert(peek() == ')');
    cur += 1;
    return n;
}
int parse() {return expression();}

C++: #include <iostream>
//#define int long long
//#define _DEBUG
//#include <vector>
#include <string>
//#include <map>
//#include <stack>
#include <cassert>
using namespace std;

//input
int N;
string input;

int cur;
int expression();

char readchar(){
    assert(cur < input.size());
    return input[cur++];
}
char peek(){
    assert(cur < input.size());
    return input[cur];
}
bool isDisit(char c){
    return int(c)>=48 && int(c)<58;
}
int disit(){
    assert(isDisit(peek()));
    return readchar() - '0';
}
int number(){
    int n = disit();
    while(cur < input.size() && isDisit(peek())){
        n = 10*n + disit();
    }
    return n;
}
char additiveOpr(){
    assert(peek()=='+' || peek()=='-');
    return readchar();
}
char multiveOpr(){
    assert(peek()=='*' || peek()=='/');
    return readchar();
}
int opr(char opr, int x, int y){
    if(opr=='+'){
        return x+y;
    }else if(opr=='-'){
        return x-y;
    }else if(opr=='*'){
        return x*y;
    }else if(opr=='/'){
        assert(y!=0);
        return x/y;
    }else{
        return -1;//error
    }
}
int factor(){
    if(peek()!='(') return number();
    cur++;
    int n = expression();
    assert(peek()==')');
    cur++;
    return n;
}
int term(){
    int r = factor();
    while(cur<input.size()
            &&(peek()=='*' || peek()=='/')){
        char o = multiveOpr();
        int b = factor();
        r = opr(o,r,b);
    }
    return r;
}
int expression(){
    int r = term();
    while(cur<input.size() 
            &&(peek()=='+' || peek()=='-')){
        char o = additiveOpr();
        int b = term();
        r = opr(o,r,b);
    }
    return r;
}
int solve(){
    int n = expression();
    assert(peek()=='=');
    return n;
}
signed main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> input;
        cur = 0;
        cout << solve() << endl;
    }
}

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++: #define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;

int p;
string S;

int num();
int factor();
int term();
int calc();

int num(){
	int n = 0;
	while(p<S.size()){
		if(isdigit(S[p])) n = n*10+S[p]-'0';
		else break;
		p++;
	}
	return n;
}

int factor(){
	int n;
	if(S[p]=='('){
		p++; n = calc(); p++;
	}
	else n = num();
	return n;
}

int term(){;
	int n = factor();
	while(p<S.size()){
		if(S[p]=='*') p++, n *= factor();
		else if(S[p]=='/') p++, n /= factor();
		else break;
	}
	return n;
}

int calc(){
	int n = term();
	while(p<S.size()){
		if(S[p]=='+') p++, n += term();
		else if(S[p]=='-') p++, n -= term();
		else break;
	}
	return n;
}

int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>S; S.pop_back();
		p = 0;
		printf("%d\n",calc());
	}
	return 0;
}

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

using namespace std;


bool isnum(string s){
  for(int i = 1; i < s.length(); i++)
    if('0' > s[i] || s[i] > '9') return false;
  
  return true;
}

int solve(string s){
  // cout << s << endl;
  if(isnum(s)){
    stringstream ss;
    int tmp;
    if(s[0] == '-'){
      ss << s.substr(1);
      ss >> tmp;
      return -1*tmp;
    }else{
      ss << s;
      ss >> tmp;
      return tmp;
    }
  }else{
    int para = 0;

    for(int i = 0; i < s.length(); i++){
      if(s[i] == '(') para++;
      if(s[i] == ')') para--;

      if((s[i] == '+' || s[i] == '-') && i && para == 0)
	if(s[i] == '+') return solve(s.substr(0,i))+solve(s.substr(i+1));
	else return solve(s.substr(0,i))-solve(s.substr(i+1));
    }

    para = 0;

    for(int i = 0; i < s.length(); i++){
      if(s[i] == '(') para++;
      if(s[i] == ')') para--;
      
      if((s[i] == '*' || s[i] == '/') && para == 0 && i)
	if(s[i] == '*') return solve(s.substr(0,i))*solve(s.substr(i+1));
	else return solve(s.substr(0,i))/solve(s.substr(i+1));
    }

    if(s[0] == '(' && s[s.length()-1] == ')')
      return solve(s.substr(1,s.length()-2));
  }
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    cout << solve(s.substr(0,s.length()-1)) << endl;
  }
  return 0;
}