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 <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<ll,const char*> parsed;

parsed expr(const char*);
parsed term(const char*);
parsed fact(const char*);

parsed expr(const char* s)
{
	//cout<<"expr(\""<<s<<"\")"<<endl;
	parsed now=term(s);
	while(*now.second=='+' || *now.second=='-'){
		char op=*now.second;
		parsed next=term(now.second+1);
		if(op=='+')
			now=parsed(now.first+next.first,next.second);
		else
			now=parsed(now.first-next.first,next.second);
	}
	//cout<<"expr(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed term(const char* s)
{
	//cout<<"term(\""<<s<<"\")"<<endl;
	parsed now=fact(s);
	while(*now.second=='*' || *now.second=='/'){
		char op=*now.second;
		parsed next=fact(now.second+1);
		if(op=='*')
			now=parsed(now.first*next.first,next.second);
		else
			now=parsed(now.first/next.first,next.second);
	}
	//cout<<"term(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed fact(const char* s)
{
	//cout<<"fact(\""<<s<<"\")"<<endl;
	//if(s[0]=='('){
	//	parsed res=expr(s+1);
	//	res.second++;
	//	return res;
	//}
	//else{
	//	const char* p=s;
	//	if(*p=='-')
	//		p++;
	//	ll n=0;
	//	while(isdigit(*p)){
	//		n=n*10+*p-'0';
	//		p++;
	//	}
	//	return parsed(n,p);
	//}
	
	if(isdigit(s[0]) || s[0]=='-'){
		const char* p=s;
		if(*p=='-')
			p++;
		ll n=0;
		while(isdigit(*p)){
			n=n*10+(*p-'0');
			p++;
		}
		return parsed(n,p);
	}
	//else if(s[0]=='('){
	//	parsed res=expr(s+1);
	//	res.second++;
	//	return res;
	//}
	//else
	//	exit(0);
	else{
		parsed res=expr(s+1);
		res.second++;
		return res;
	}
}

int main()
{
	string s;
	getline(cin,s);
	while(getline(cin,s))
		cout<<expr(s.c_str()).first<<endl;
	
	return 0;
}

C++: #include<iostream>
#include<cstdlib>
using namespace std;
typedef pair<int,const char*>parsed;
parsed expr(const char *p);
parsed term(const char *p);
parsed fact(const char *p);
parsed expr(const char *p){
  parsed r=term(p);
 while(*r.second=='+'||*r.second=='-'){
    char op =*r.second;
    int tmp=r.first;
    r=term(r.second+1);
    if(op=='+')r.first=tmp+r.first;
    else r.first=tmp-r.first;
  }
  return r;
}
parsed term(const char *p){
  parsed r=fact(p);
  while(*r.second=='*'||*r.second=='/'){
    char op=*r.second;
    int tmp=r.first;
    r=fact(r.second+1);
    if(op=='*')r.first=tmp*r.first;
    else r.first=tmp/r.first;
  }
  return r;
}
parsed fact(const char *p){
  if(isdigit(*p)){
    int t=*(p++)-'0';
    while(isdigit(*p))t=t*10+*(p++)-'0';
    return parsed(t,p);
  }
  else if(*p=='('){
    parsed r=expr(p+1);
    if(*r.second!=')')exit(0);
    return parsed(r.first,r.second+1);
  }
  else exit(0);
}
main(n){
  string str;
  cin>>n;
  while(n--){
	  cin>>str;
    cout<<expr(str.c_str()).first<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int culc1();
int culc2();
int culc3();
int culc4();

int n;
string str;
int cur;

int main() {
	cin >> n;
	while (n--) {
		cin >> str;
		cur = 0;
		cout << culc1() << endl;
	}
	return 0;
}


int culc1() {
	int val = culc2();
	while (str[cur] == '+' || str[cur] == '-') {
		char op = str[cur++];
		int val2 = culc2();

		if (op == '+') val += val2;
		else val -= val2;
	}
	return val;
}

int culc2() {
	int val = culc3();
	while (str[cur] == '*' || str[cur] == '/') {
		char op = str[cur++];
		int val2 = culc3();
		
		if (op == '*') val *= val2;
		else val /= val2;
	}
	return val;
}

int culc3() {
	if (isdigit(str[cur])) return culc4();
	cur++;
	int res = culc1();
	cur++;
	return res;
}

int culc4() {
	int num = str[cur++] - '0';
	while (isdigit(str[cur]))
		num = num*10 + str[cur++] - '0';
	return num;
}

C++: /*
<expr>   ::= <term> [ ('+'|'-') <term> ]*
<term>   ::= <factor> [ ('*'|'/') <factor> ]*
<factor> ::= <number> | '(' <expr> ')'
<number> :== 1つ以上の数字
*/

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int main(){
	int n;
	cin >> n;
	for(int j = 0; j < n; j++){
		string str;
		cin >> str;
		int i = 0;
		
		cout << expr(str, i) << endl;
	}
	
	return 0;
}

int expr(string& s, int& i){
	int val = term(s, i);

	while(s[i] == '+' || s[i] == '-'){
		char op = s[i++];
		int val2 = term(s, i);
		if(op == '+')
			val += val2;
		else
			val -= val2;
	}
	
	return val;
}

int term(string& s, int& i){
	int val = factor(s, i);
	while(s[i] == '*' || s[i] == '/'){
		char op = s[i++];
		int val2 = factor(s, i);
		if(op == '*')
			val *= val2;
		else
			val /= val2;
	}
	
	return val;
}

int factor(string& s, int& i){
	if(isdigit(s[i]))
		return number(s, i);
	
	i++;
	int ret = expr(s, i);
	i++;
	
	return ret;
}

int number(string& s, int& i){
	int n = s[i++] - '0';
	while(isdigit(s[i]))
		n = n * 10 + s[i++] - '0';
	
	return n;
}