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 <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;

string lltostr(ll n) {
  // cout << "lltostr " << n << endl;
  stringstream ss;
  ss << n;
  return ss.str();
}

ll calc(string str) {
  // ©Á±ª êÎêÔOÌ©Á±ðÍ¸·
  int p = 0, s = 0;
  // cout << "before " << str << endl;
  REP(i,str.length()) {
    if (str[i] == '(') {
      p++;
      if (p==1)
        s = i;
    }
    if (str[i] == ')') {
      if (p==1) {
        string tmp = lltostr(calc(str.substr(s+1,i-s-1)));
        str = str.substr(0,s) + tmp + str.substr(i+1);
        i = s + tmp.length()-1;
      }
      p--;
    }
  }
  p = -1;
   // cout << "remove () " << str << endl;
  REP(i,str.length()) {
    char c = str[i];
    if (c=='*' || c=='/') {
      string a = str.substr(p+1,i-p-1);
      int q = i;
      string b;
      for(i++;i<str.length();i++) {
        if (i!=q+1 && !isdigit(str[i])) {
          b = str.substr(q+1,i-q-1);
          break;
        }
      }
      if (i == str.length())
        b = str.substr(q+1);
      string tmp;
      if (c=='*')
        tmp = lltostr(atoll(a.c_str()) * atoll(b.c_str()));
      else if (c=='/')
        tmp = lltostr(atoll(a.c_str()) / atoll(b.c_str()));
      str = str.substr(0,p+1) + tmp + str.substr(i);
      i = p + tmp.length();
    }
    if (!isdigit(str[i])) {
      p = i;
    }
  }
  // cout << "cal *|/ " << str << endl;
  p = -1;
  REP(i,str.length()) {
    char c = str[i];
    if (c=='+' || c=='-') {
      string a = str.substr(p+1,i-p-1);
      int q = i;
      string b;
      for(i++;i<str.length();i++) {
        if (i!=q+1 && !isdigit(str[i])) {
          b = str.substr(q+1,i-q-1);
          break;
        }
      }
      if (i == str.length())
        b = str.substr(q+1);
      string tmp;
      if (c=='+')
        tmp = lltostr(atoll(a.c_str()) + atoll(b.c_str()));
      else if (c=='-')
        tmp = lltostr(atoll(a.c_str()) - atoll(b.c_str()));
      str = str.substr(0,p+1) + tmp + str.substr(i);
      i = p + tmp.length();
    }
    if (!isdigit(str[i])) {
      p = i;
    }
  }
  // cout << "cal +|- " << str << endl;
  return atoll(str.c_str());
}

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    string s;
    getline(cin,s);
    s = s.substr(0,s.length()-1);
    cout << calc(s) << endl;
  }
}

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 <math.h>
#include <vector>
#include <set>
#include <stack>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
int tenp(int n){
  int ret = 1;
  REP(i,n)
    ret *= 10;
  return ret;
}

int cal(){
  stack<int> st;
  int ope=0;
  int num;
  while(true){
    char c = getchar();
    if(c == '(' || ('0'<=c && c<= '9') ) {
      if(c == '(') num = cal();
      else{
        int dig=0;
        int numd[10]={0};
        numd[0] = (c - '0');
        while(true){
          c = getchar();
          if(!('0'<=c&&c<='9')) break;
          dig++;
          numd[dig] = (c - '0');
        }
        num = 0;
        for(int i=dig; i>=0; i--)
          num+=numd[dig-i] * tenp(i);
      }
      if(ope==0){
        st.push(num);
      }else if(ope == 1){
        st.push(-num);
        ope = 0;
      }else if(ope == 2){
        int tmp = st.top();
        st.pop();
        st.push(tmp * num);
        ope = 0;
      }else if(ope == 3){
        int tmp = st.top();
        st.pop();
        st.push(tmp / num);
        ope = 0;
      }
    }
    if(c == ')' ) break;
    if(c == '=' ){
      getchar();
      break;
    }
    if(c == '+') ope = 0;
    if(c == '-') ope = 1;
    if(c == '*') ope = 2;
    if(c == '/') ope = 3;
  }
  int sum=0;
  while(!st.empty()){
    sum += st.top();
    st.pop();
  }
  return sum;
}

int main(void){  
  int n;
  cin >> n;
  getchar();
  REP(i,n)
    cout << cal() << endl;
  return 0;
}

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

using namespace std;

char s[111];
int cur,len;

int shiki();

int kazu()
{
  if( s[cur] == '(' ) {
    cur += 1;
    return shiki();
  } else {
    int a = s[cur]-'0';
    cur += 1;
    while( isdigit(s[cur]) ) {
      a *= 10;
      a += s[cur]-'0';
      cur += 1;
    }
    return a;
  }
}          

int kou()
{
  int a = kazu();
  while( s[cur] == '*' || s[cur] == '/' ) {
    char o = s[cur]; cur += 1;
    int b = kazu();
    o=='*'?(a*=b):(a/=b);
  }
  return a;
}

int shiki()
{
  int a = kou();
  while( s[cur] == '+' || s[cur] == '-' ) {
    char o = s[cur]; cur += 1;
    int b = kou();
    if( o == '+' ) a += b;
    else a -= b;
  }
  return a;
}

int parse()
{
  len = 0;
  while( s[len] ) len++;
  len--;
  cur = 0;
  return shiki();
}

int main(void)
{
  int n; scanf("%d",&n);
  while( n-- ) {
    scanf("%s",s);
    printf("%d\n",parse());
  }
  return 0;
}