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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string::const_iterator State;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

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

bool isdigit(char in) {
    if((in <= '9') && (in >= '0')) return true;
    else return false;
}

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);
    for(;;) {
        if(*begin == '*'){
            begin++;
            ret *= factor(begin);
            continue;
        }
        if(*begin == '/'){
            begin++;
            ret /= factor(begin);
            continue;
        }
        break;
    }
    return ret;
}

int expression(State &begin) {
    int ret = term(begin);
    for(;;) {
        if(*begin == '+'){
            begin++;
            ret += term(begin);
            continue;
        }
        if(*begin == '-'){
            begin++;
            ret -= term(begin);
            continue;
        }
        break;
    }
    return ret;
}

int factor(State &begin) {
    int ret;
    if(*begin == '(') {
        begin++;
        ret = expression(begin);
        begin++;
    } else {
        ret = number(begin);
    }
    return ret;
}
int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    cin.ignore();
    while(n--){
        string s;
        getline(cin, s);
        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef string::const_iterator State;

int expression(State &begin);

int term(State &begin);

int factor(State &begin);

int number(State &begin);

void consume(State &begin,char expected);

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    State begin = s.begin();
    int ans=expression(begin);
    consume(begin,'=');
    cout<<ans<<endl;
  }

}


int number(State &begin){
  int ret = 0;

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


int factor(State &begin){
  if(*begin =='('){
    consume(begin,'(');
    int ret = expression(begin);
    consume(begin,')');
    return ret;
  }
  else{
    return number(begin);
  }
}


int term(State &begin){
  int ret = number(begin);

  for(;;){
    if(*begin =='*'){
      consume(begin,'*');
      ret *= factor(begin);
    }
    else if(*begin =='/'){
      consume(begin,'/');
      ret /= factor(begin);
    }
    else break;
  }

  return ret;
}


int expression(State &begin){
  int ret = term(begin);

  for(;;){
    if(*begin =='+'){
      consume(begin,'+');
      ret += term(begin);
    }
    else if(*begin =='-'){
      consume(begin,'-');
      ret -= term(begin);
    }
    else break;
  }
  return ret;
}



void consume(State &begin, char expected) {
  if (*begin == expected) {
    begin++;
  } else {
    cerr << "Expected '" << expected << "' but got '" << *begin << "'"
      << endl;
    cerr << "Rest string is '";
    while (*begin) {
      cerr << *begin++;
    }
    cerr << "'" << endl;
  }
}

C++: #include <iostream>
#include <string>
using namespace std;

int hyoka(string);
int isNum(int);

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


int hyoka(string s){
	long int total=0,work=0;
	long int tmp1,tmp2;
	int oi=0;
	char oc;
	int n;
	string cs;
	
	if(s[oi]=='(' || isNum(s[oi])!=-1){s="+"+s;}
	//cout<<s<<endl;

	while(1){
	 oc=s[oi];if(oc=='='){total+=work;break;}
	 
	 if(s[oi+1]!='('){	//??°???????????????
	  tmp1=0;
	  while(1){
	   oi++;
	   tmp2=isNum(s[oi]);
	   if(tmp2!=-1){tmp1=tmp1*10+tmp2;}else{break;}
	  }
	 }else{	//??????????????°
	  cs="";n=1;oi++;
	  while(1){
	   oi++;
	   switch(s[oi]){
		case '(':n++;break;
		case ')':n--;break;
	   }
	   if(n!=0){cs+=s[oi];}else{break;}
	  }
	  cs+='=';
	  //cout<<cs<<endl;
	  tmp1=hyoka(cs);
	 }
	
	 switch(oc){
	  case '+':total+=work;work=tmp1;break;
	  case '-':total+=work;work=-tmp1;break;
	  case '*':work*=tmp1;break;
	  case '/':work/=tmp1;break;
	 }
	}
	
	return total;
}

int isNum(int c){
	if(48<=c && c<=57){
	 return c-48;
	}
	return -1;
}

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])){
		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);
		if (*res.second!=')') exit(0);
		res.second++;
		return res;
	}
	else
		exit(0);
}

//parsed fact(const char *p)
//{
//  if (isdigit(*p)){
//    int t=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); // invalid input
//    return parsed(r.first,r.second+1);
//  }
//  else
//    exit(0); // invalid input
//}

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