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<stack>
#include<iostream>
#include<sstream>
#include<string>
#include<cstdlib>
using namespace std;
string its(int n){
  stringstream s;
  s<<n;
  return s.str();
}
stack<string> mep(stack<string> me,string s){
  int a,b;
  b=atoi(me.top().c_str());
  me.pop();
  a=atoi(me.top().c_str());
  me.pop();
  if(s=="+")
    me.push(its(a+b));
  else if(s=="-")
    me.push(its(a-b));
  else if(s=="*")
    me.push(its(a*b));
  else if(s=="/")
    me.push(its(a/b));
  return me;
}
int main(){
  int h,i,j;
  int n,len;
  string s;
  stack<string> me,st;
  cin>>n;
  for(h=0;h<n;h++){
    cin>>s;
    len=s.length()-1;
    for(i=0;i<len;i++){
      if('1'<=s[i]&&s[i]<='9'){
	for(j=i;j<len;j++)
	  if(s[j]<'0'||'9'<s[j])
	    break;	
	me.push(s.substr(i,j-i));
	i=j-1;
      }else if(s[i]=='('){
	st.push(s.substr(i,1));
      }else if(s[i]==')'){
	while(st.top()!="("){
	  me=mep(me,st.top());
	  st.pop();
	}
	st.pop();
      }else if(s[i]=='+'||s[i]=='-'){
	if(st.empty());
	else if(st.top()=="(");
	else{
	  while(st.empty()==0){
	    if(st.top()=="(")
	      break;
	    else{
	      me=mep(me,st.top());
	      st.pop();
	    }
	  }
	}
	st.push(s.substr(i,1));
      }else if(s[i]=='*'||s[i]=='/'){
	if(st.empty());
	else if(st.top()=="(");
	else if(st.top()=="+"||st.top()=="-");
	else{
	  while(st.empty()==0){
	    if(st.top()=="(")
	      break;
	    else if(st.top()=="+"||st.top()=="-")
	      break;
	    else{
	      me=mep(me,st.top());
	      st.pop();
	    }
	  }
	}
	st.push(s.substr(i,1));
      }
    }
    while(st.empty()==0){
      me=mep(me,st.top());
      st.pop();
    }
    cout<<me.top()<<endl;
    me.pop();
  }
  return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

typedef string::iterator state;

lli addsub(state& s);
lli muldiv(state& s);
lli parent(state& s);
lli number(state& s);

lli number(state& s){
	lli res = 0;
	if(*s=='('){
		res = parent(s);
	}
	else if('0'<=*s && *s<='9'){
		while('0'<=*s && *s<='9'){
			res*=10;
			lli nc = *s-'0';
			res += nc;
			s++;
		}
	}
	else printf("error number\n");
	return res;
}

lli parent(state& s){
	if(*s!='(')printf("error kakko\n");
	s++;
	lli res = addsub(s);
	if(*s!=')')printf("error kokka\n");
	s++;
	return res;
}

lli muldiv(state& s){
	lli res = number(s);
	while(1){
		if(*s=='*'){
			s++;
			res *= number(s);
		}
		else if(*s=='/'){
			s++;
			res /= number(s);
		}
		else break;
	}
	return res;
}

lli addsub(state& s){
	lli res = muldiv(s);
	while(1){
		if(*s=='+'){
			s++;
			res += muldiv(s);
		}
		else if(*s=='-'){
			s++;
			res -= muldiv(s);
		}
		else break;
	}
	return res;
}


int main(void){
	int n;
	scanf("%d",&n);
	rep(i,n){
		char s[105];
		scanf("%s",s);
		string ns(s);
		state is = ns.begin();
		printf("%lld\n",addsub(is));
		if(*is!='=')printf("error finish\n");
	}
	return 0;
}

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

int Parse(string a) {
	int s = 0;
	for (int b = 0; b < a.length(); b++) {
		s *= 10;
		s += a[b] - 48;
	}
	return s;
}
int main() 
{
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		vector<int>c;
		vector<char>d;
		string e;
		cin >> e; string g = "";
		for (int f = 0; f < e.length()-1; f++) {
			if (e[f]<'0' || e[f]>'9') { c.push_back(Parse(g)); g = ""; d.push_back(e[f]); }
			else g += e[f];
		}
		c.push_back(Parse(g));
		for (int o = 0; o < d.size(); o++) {
			if (d[o] == '*') {int q= c[o] * c[o + 1]; c[o + 1] =q; c[o] = q; }
			else if (d[o] == '/') { int q = c[o] / c[o + 1]; c[o + 1] = q; c[o] = q; }
		}
		int s = c[0];
		for (int k = 0; k < d.size(); k++) {
			if (d[k] == '+')s += c[k+1];
			else if (d[k] == '-')s -= c[k+1];
		}
		cout << s << endl;
	}
}

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

int main() {
	/*const*/ string s;
	stack<int> num;
	stack<int> mar;
	int n1, n2;
	cin >> s;
	for ( int i = 0; i < 100; i++ ) {
		if ( s.substr( i, 1 ) == "+" ) {
			if ( mar.top() == 0 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 + n2 );
				mar.pop();
			} else if ( mar.top() == 1 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 - n2 );
				mar.pop();
			}
			mar.push(0);
		} else if ( s.substr( i, 1 ) == "-" ) {
			mar.push(1);
			if ( mar.top() == 0 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 + n2 );
				mar.pop();
			} else if ( mar.top() == 1 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 - n2 );
				mar.pop();
			}
		} else if ( s.substr( i, 1 ) == "*" ) mar.push(2);
		else if ( s.substr( i, 1 ) == "/" ) mar.push(3);
		else if ( s.substr( i, 1 ) == "(" ) mar.push(4);
		else if ( s.substr( i, 1 ) == ")" ) {
			if ( mar.top() == 0 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 + n2 );
				mar.pop();
			} else if ( mar.top() == 1 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 - n2 );
				mar.pop();
			}
				mar.pop();
		} else if ( s.substr( i, 1 ) == "=" ) {
			if ( mar.top() == 0 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 + n2 );
				mar.pop();
			} else if ( mar.top() == 1 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 - n2 );
				mar.pop();
			}
			cout << num.top();
			break;
		} else {
			n2 = atoi( s.c_str() );
			if ( mar.top() == 2 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 * n2 );
				mar.pop();
			} else if ( mar.top() == 3 ) {
				n1 = num.top();
				num.pop();
				num.push( n1 / n2 );
				mar.pop();
			}
		}
	}		
}

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

double calc2(char *eq){
	long c=0, sign[100]={0};
	double num[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c-1;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c-1;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

long long int calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	long k,ret;
	strcpy(cp, eq);
	if((p=strchr(cp, '('))!=NULL){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%ld%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return (long long int)calc2(cp);
}

int main(){
	long i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
	return 0;
}