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<vector>
#include<algorithm>
#include<cassert>
using namespace std;
#define INF (1<<24)

bool isNum(char ch){return ('0'<=ch&&ch<='9');}

struct calcStr{
  string s;
  int pos,len;

  void init(){ pos=0;len=s.size();}

  int head2Num(){
    //bool f=false;
    //if(s[pos]=='-'){f=true;pos++;}
    int res=0;
    while(pos<len){
      if(isNum(s[pos])){
	res*=10;
	res+=(s[pos]-'0');
	pos++;
      }else break;
    }
    //if(f)res*=-1;
    return res;
  }
  
  int getNum(){
    if(s[pos]=='('){
      pos++;
      return getAns();
    }
    int res=head2Num();
    if(s[pos]=='*'){
      pos++;
      return res*getNum();
    }else if(s[pos]=='/'){
      pos++;
      return res/getNum();
    }else{
      return res;
    }
  }
  
  int getAns(){
    int res=getNum(),num;
    while(1){
      if(s[pos]==')'){pos++;break;}
      if(s[pos]=='=')break;
      char ch=s[pos++];
      num=getNum();
      if(ch=='+')res+=num;
      else if(ch=='-')res-=num;
      else assert(0);
    }
    return res;
  }
};

int main(){
  int Tc;cin>>Tc;
  calcStr a;
  while(Tc--){
    cin>>a.s;
    a.init();
    cout<<a.getAns()<<endl;
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <stdio.h>

typedef enum{
	INT,
	PLUS,
	MINUS,
	MUL,
	DIV,
	EQ,
	LPAREN,
	RPAREN,
	NL
} token_kind_t;

typedef struct token{
	int c;
	token_kind_t kind;
	int ival;
} *token_t;

int calc_expr_add(token_t t);

token_t next_tok(token_t t)
{
	while (t->c == ' ' || t->c == '\n') {
		t->c = getchar();
	}
	if (isdigit(t->c)){
		t->ival = 0;
		t->kind = INT;
		while (isdigit(t->c)){
			t->ival *= 10;
			t->ival += t->c - '0';
			t->c = getchar();
		}
	}
	else{
		if (t->c == '+') t->kind = PLUS;
		else if (t->c == '-') t->kind = MINUS;
		else if (t->c == '*') t->kind = MUL;
		else if (t->c == '/') t->kind = DIV;
		else if (t->c == '(') t->kind = LPAREN;
		else if (t->c == ')') t->kind = RPAREN;
		else if (t->c == '=') t->kind = EQ;
		else if (t->c == '\n') t->kind = NL;
		else exit(1);

		t->c = getchar();
	}

	return t;
}

token_t mk_tok()
{
	token_t t;
	if ((t = (token_t)malloc(sizeof(struct token))) == NULL){
		perror("malloc");
		exit(1);
	}

	t->c = getchar();

	return t;
}

int calc_expr_un(token_t t)
{
	int ret = 0;
	if (t->kind == INT){
		ret = t->ival;
		next_tok(t);
	}
	else if (t->kind == LPAREN){
		next_tok(t);
		ret = calc_expr_add(t);
		if (t->kind != RPAREN) exit(1);
		next_tok(t);
	}
	else if (t->kind == PLUS || t->kind == MINUS){
		if (t->kind == PLUS){
			next_tok(t);
			ret += calc_expr_un(t);
		}
		else {
			next_tok(t);
			ret -= calc_expr_un(t);
		}
	}
	else exit(1);
	return ret;
}

int calc_expr_mul(token_t t)
{
	int ret = 0;
	ret = calc_expr_un(t);
	while (t->kind == MUL || t->kind == DIV){
		if (t->kind == MUL){
			next_tok(t);
			ret *= calc_expr_un(t);
		}
		else {
			next_tok(t);
			ret /= calc_expr_un(t);
		}
	}
	return ret;
}

int calc_expr_add(token_t t)
{
	int ret = 0;
	ret = calc_expr_mul(t);
	while (t->kind == PLUS || t->kind == MINUS){
		if (t->kind == PLUS){
			next_tok(t);
			ret += calc_expr_mul(t);
		}
		else {
			next_tok(t);
			ret -= calc_expr_mul(t);
		}
	}
	return ret;
}

int calc_expr(token_t t)
{
	int ret = 0;

	next_tok(t);
	ret = calc_expr_add(t);
	if (t->kind != EQ) exit(1);

	return ret;
}

int main()
{
	int n;

	n = getchar() - '0';
	getchar();

	token_t t = mk_tok();

	int i;
	for (i = 0; i < n; i++){
		int result = calc_expr(t);
		printf("%d\n", result);
	}

	return 0;
}

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

using namespace std;

string s;

int stoi(string str) {
	int len = (int)str.size();
	if (len==0) return 0;
	return (str[len - 1] - '0') + 10 * ( stoi(str.substr(0, len - 1)) );
}

int parse(int l, int r) {
	int k = 0;
	
	// +, -
	for (int i=r-1; i>=l; i--) {
		if (s[i]=='(') k++;
		if (s[i]==')') k--;
		if (k==0 && s[i]=='+') return parse(l, i) + parse(i+1, r);
		if (k==0 && s[i]=='-') return parse(l, i) - parse(i+1, r);
	}
	
	// *,/
	for (int i=r-1; i>=l; i--) {
		if (s[i]=='(') k++;
		if (s[i]==')') k--;
		if (k==0 && s[i]=='*') return parse(l, i) * parse(i+1, r);
		if (k==0 && s[i]=='/') return parse(l, i) / parse(i+1, r);
	}
	
	if (s[l] == '(' && s[r-1] == ')') return parse(l+1, r-1);
	
	return stoi(s.substr(l, r-l));
}

int main() {
	int n; cin >> n;
	
	for (int i=0; i<n; i++) {
		cin >> s;
		cout << parse(0, (int)s.size()-1) << endl;
	}
	
	return 0;
}