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++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;

const int INF=1e9;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-10;
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003


int dp[353][353]={0};
int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}
int cards[10];
bool ok;
void saiki(int deep){
	if(deep==4){
		ok=true;
		return;
	}
	for(int i=1;i<=7;i++){
		if(cards[i]>0&&cards[i+1]>0&&cards[i+2]>0){
			cards[i]--;
			cards[i+1]--;
			cards[i+2]--;
			saiki(deep+1);
			cards[i]++;
			cards[i+1]++;
			cards[i+2]++;
		}
		for(int i=1;i<=9;i++){
			if(cards[i]>2){
				cards[i]-=3;
				saiki(deep+1);
				cards[i]+=3;
			}
		}
	}
	
}

int main(){
	
	int n;
	cin>>n;
	while(n>0){
		stack<string> a;
	string s;
		cin>>s;
		string tmp="";
		rep(i,s.size()){
			if(s[i]>='0'&&s[i]<='9'){
				tmp+=s[i];
			}
			else{
				if(!a.empty()&&s[i]!='('){
				string o=a.top();
					int k=0;
				if(o=="*"){
					a.pop();
					k=stoi(tmp)*stoi(a.top());
					a.pop();
					tmp=to_string(k);
					
				}
				else if(o=="/"){
					a.pop();
					k=stoi(a.top())/stoi(tmp);
					a.pop();
					tmp=to_string(k);
				
				}
					
					
				}
				if(tmp!=""){
				a.push(tmp);
				tmp="";
				}
					if(s[i]==')'){
						int k=stoi(a.top());
						a.pop();
							while(1){
									if(a.top()=="("){
										a.pop();
										if(!a.empty()){
											if(a.top()=="*"){
											a.pop();
												k=stoi(a.top())*k;
												a.pop();
											}
											else if(a.top()=="/"){
												a.pop();
												k=stoi(a.top())/k;
												a.pop();
											}
												
										}
										a.push(to_string(k));
										break;
									}
										else{
												if(a.top()=="+"){
									a.pop();
									k=k+stoi(a.top());
								}
								else if(a.top()=="-"){
									a.pop();
									k=stoi(a.top())-k;
								}
								a.pop();
										}
							}
								
						
					}
						else if(s[i]!='='){
							
							if(i==0&&s[i]=='-')
								tmp+=s[i];
							else if(s[i+1]=='-'){
								tmp+=s[i+1];
								string c="";
							c+=s[i++];
							a.push(c);
						}
							else{
								string c="";
							c+=s[i];
							a.push(c);
							}
							
						}
					
			}
				
		}
			int ans=stoi(a.top());
			a.pop();
			while(!a.empty()){
				if(a.top()=="+"){
				a.pop();
					ans=ans+stoi(a.top());
				}
				else if(a.top()=="-"){
				a.pop();
					ans=stoi(a.top())-ans;
				}
				a.pop();
				
			}
			cout<<ans<<endl;
			n--;
	}
	
}

C++: #include <iostream>
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(isNum(s[oi])==-1){s="+"+s;}
	
	while(1){
	 oc=s[oi];if(oc=='='){total+=work;break;}
	 
	 if(s[oi+1]!='('){	//??°???????????????
	  tmp1=0;
	  while(1){
	   oi++;
	   tmp2=s[oi];
	   if(tmp2!=-1){tmp1=tmp1*10+tmp2;}else{break;}
	  }
	 }else{	//??????????????°
	  cs="";n=1;oi++;
	  while{
	   oi++;
	   switch(s[oi]){
		case '(':n++;break;
		case ')':n--;break;
	   }
	   if(n!=0){cs+=s[oi];}else{break;}
	  }
	  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(49<=c && c<=57){
	 return c-49;
	}
	return -1;
}

C++: // 0109 wa solution?????§
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <stack>
#include <vector>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

void calc(string st, stack<ll> &s) {	
	if(st == "*") {
		ll a = s.top();
		s.pop();
		ll b = s.top();
		s.pop();
		s.push(a * b);
	} else if(st == "+") {
		ll a = s.top();
		s.pop();
		ll b = s.top();
		s.pop();
		s.push(a + b);
	} else if(st == "-") {
		ll a = s.top();
		s.pop();
		ll b = s.top();
		s.pop();
		s.push(b - a);
	} else if(st == "/") {
		ll a = s.top();
		s.pop();
		ll b = s.top();
		s.pop();
		s.push(b / a);
	} else {
		s.push(atoi(st.c_str()));
	}
}
int getPriority(string s) {
	if(s == "(") {
		return 5;
	} else if(s == "*" || s == "/") {
		return 3;
	} else if(s == "+" || s == "-") {
		return 2;
	} else if(s == ")") { 
		return 1;
	} else return 4;
}

int main() {
	int n;
	cin >> n;
	while(n--) {
		string str;
		cin >> str;
		str.erase(--str.end());
		
		vector<string> v;
		
		int f = 0;
		char prev = '(';
		bool minus = 0;
		rep(i, str.size()) {		
			if(isdigit(str[i])) {
				f++;
			} else {
				if(f) {
					string st;
					if(minus) {
						st += '-';
						minus = 0;
					}
					rep(j,f) {
						st += str[i - f + j];
					}	
					v.push_back(st);
					string st2;
					st2 += str[i];
					v.push_back(st2);
					f = 0;
				} else {
					if(prev == '(' && str[i] == '-') {
						minus = 1;
						prev = str[i];
						continue;
					}
					string st3;
					st3 += str[i];
					v.push_back(st3);
				}
			}
			prev = str[i];
		}
		if(f) {
			string st;
			rep(j,f) {
				st += str[str.size() - f + j];
			}
			v.push_back(st);
		}

		stack<string> s;
		vector<string> nv;
		stack<ll> ret;
		int p = 0;
		rep(i,v.size()) {
			cout << v[i] << endl;
		}
		rep(i,v.size()) {
			p = getPriority(v[i]);
			while(!s.empty() && getPriority(s.top()) > p && s.top() != "(") {
				nv.push_back(s.top());
				s.pop();
			}
			if(v[i] == ")") {
				s.pop();
			} else {
				s.push(v[i]);
			}
		}
		while(!s.empty()) {
			nv.push_back(s.top());
			s.pop();
		}
		rep(i,nv.size()) {
			calc(nv[i], ret);
		}
		cout << ret.top() << endl;
	}
	return 0;
}