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 <string>
#include <map>
#include <algorithm>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int n;
string str;

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

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

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

int term(State &begin)
{
	int ret = factor(begin);
	while (true)
	{
		if (*begin == '*')
		{
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/')
		{
			begin++;
			ret /= factor(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}

int expressin(State &begin)
{
	int ret = term(begin);
	while (true)
	{
		if (*begin == '+')
		{
			begin++;
			ret += term(begin);
		}
		else if (*begin == '-')
		{
			begin++;
			ret -= term(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}


int main()
{
	cin >> n;
	while (n--)
	{
		cin >> str;
		cout << expressin(str.begin()) << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cassert>
#include <algorithm>
using namespace std;
 
char *pt;
int parseAtom();
int parseExpr();
int parseTerm();
int parseAtom() {
  if('0' <= *pt && *pt <= '9') {
    int x = *pt-'0';
    pt++;
    while('0' <= *pt && *pt <= '9') {
      x = x*10 + *pt-'0';
      pt++;
    }
    return x;
  }
  if('(' == *pt) {
    pt++;
    int x = parseExpr();
    assert(*pt == ')');
    pt++;
    return x;
  }
  assert(false);
  return -1;
}
int parseExpr() {
  int x = parseTerm();
  while(*pt == '+' || *pt == '-') {
    if(*pt == '+') {
      pt++;
      x += parseTerm();
    } else {
      pt++;
      x -= parseTerm();
    }
  }
  return x;
}
int parseTerm() {
  int x = parseAtom();
  while(*pt == '*' || *pt == '/') {
    if(*pt == '*') {
      pt++;
      x *= parseAtom();
    } else {
      pt++;
      x /= parseAtom();
    }
  }
  return x;
}
 
int main() {
  int tc; scanf("%d", &tc);
  for(int tci = 0; tci < tc; tci++) {
    static char expr[200]; scanf(" %s", expr);
    pt = expr;
    int x = parseExpr();
    assert(*pt == '=');
    printf("%d\n", x);
  }
  return 0;
}

C++: 
#include <iostream>
#include <string>
#include <cctype>
#include <stdlib.h>

using namespace std;

string ex_s; //expression_string
int n;

int cal(string ex_s) //calculate expression_string
{
    int i;
    int j;
    int ans; //answer
    int cnt_p=0; //count_parentheses
    int cnt_pp=1;
    int cnt_as=0; //count_add subtract
    int cnt_md=0; //count_nultiply divide
    for(i=0;i<ex_s.size();i++)
    {
        if(ex_s[i]=='(')
        {
            for(j=i+1;j<ex_s.size();j++)
            {
                if(ex_s[j]=='(') cnt_pp+=1;
                else if(ex_s[j]==')')
                {
                    cnt_pp-=1;
                    if(cnt_pp==0)
                    {
                        cnt_pp=1;
                        break;
                    }
                }
            }
            ans=cal(ex_s.substr(i+1,j-i-1));
            ex_s=ex_s.substr(0,i)+to_string(ans)+ex_s.substr(j+1);
            i=j;
            cnt_p+=1;
        }
    }
    if(cnt_p!=0)
    {
        return cal(ex_s);
    }
    else
    {   for(i=0;i<ex_s.size();i++)
        {
            if(ex_s[i]=='+')
            {
                ans=cal(ex_s.substr(0,i))+cal(ex_s.substr(i+1));
                cnt_as+=1;
                return ans;
                break;
            }
            else if(ex_s[i]=='-')
            {
                if(i==0) ans=0-cal(ex_s.substr(i+1));
                else ans=cal(ex_s.substr(0,i))-cal(ex_s.substr(i+1));
                cnt_as+=1;
                return ans;
                break;
            }
        }
        if(cnt_as==0)
        {
            for(i=0;i<ex_s.size();i++)
            {
                if(ex_s[i]=='*')
                {
                    ans=cal(ex_s.substr(0,i))*cal(ex_s.substr(i+1));
                    cnt_md+=1;
                    return ans;
                    break;
                }
                else if(ex_s[i]=='/')
                {
                    ans=cal(ex_s.substr(0,i))/cal(ex_s.substr(i+1));
                    cnt_md+=1;
                    return ans;
                    break;
                }
            }
            if(cnt_md==0)
            {
                return atoi(ex_s.c_str());
            }
        }
    }
}

int main()
{
    cin >> n;
    while(n--)
    {
        cin >> ex_s;
        ex_s.pop_back();
        cout << cal(ex_s) << endl;
    }
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
// const string S = "(1+1)*2";
string S;
int cur = 0;
int digit();
int number();
int factor();
int term();
int _term(int m);
int exp();
int _exp(int m);
int parse();
bool isdigit(char);
bool is_plu_min(char);
bool is_tim_div(char);
int main() {
  int N;
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> S;
    cur = 0;
    S.resize(S.size()-1);
    cout << parse() << endl;
  }
  return 0;
}
int digit() {
  int n = S[cur] - '0';
  cur++;
  return n;
}
int number() {
  int n = digit();
  while (cur < S.size() && isdigit(S[cur]))
    n = n*10 + digit();
  return n;
}
bool isdigit(char c) {
  if (c <= '9' and c >= '0') return true;
  else return false;
}
bool is_plu_min(char c) {
  if (c == '+' || c == '-') return true;
  else return false;
}
bool is_tim_div(char c) {
  if (c == '*' || c == '/') return true;
  else return false;
}
// exp    = term exp`
// exp`   = + term exp` | eps
// term   = factor term`
// term`  = * factor term` | eps
// factor = ( exp ) | num
int term() {
  int n = factor();
  return _term(n);
}
int _term(int m) {
  int n = m;
  switch (S[cur]) {
    case '*':
      cur++;
      n *= factor();
      return _term(n);
    case '/':
      cur++;
      n /= factor();
      return _term(n);
    default:
      return n;
  }
}
int factor() {
  if (S[cur] != '(') return number();
  else {
    cur++;
    int n = exp();
    cur++;
    return n;
  }
}
int exp() {
  int n = term();
  return _exp(n);
}
int _exp(int m) {
  int n = m;
  switch (S[cur]) {
    case '+':
      cur++;
      n += term();
      return _exp(n);
    case '-':
      cur++;
      n -= term();
      return _exp(n);
    default:
      return n;
  }
}
int parse() {
  return exp();
}