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 <stdio.h>
#include <assert.h>
#include <stack>

char buf[128];
int pos;
#define NOW (buf[pos])

bool isdigit(char c) {
	return ('0' <= c && c <= '9');
}

bool isstrong(char c) {
	return (c=='*'||c=='/');
}
bool isweak(char c) {
	return (c=='+'||c=='-');
}

int digit() {
	if ( !isdigit(NOW) ) {
		fprintf(stderr, "%c: ", NOW);
		assert( isdigit(NOW) );
	}
	int ret = NOW - '0';
	pos++;
	
	return ret;
}
int number() {
	int ret = digit();
	while( isdigit(NOW) ) {
		ret = ret*10 + digit();
	}
	return ret;
}

int main(void) {

	int set;
	scanf("%d", &set);
	
	while(set--) {
		scanf("%s", buf);
		std::stack<char> expr;
		std::stack<int>  num;
		
		expr.push('(');
		
		while(true) {
			if(isdigit(NOW)) {
				num.push( number() );
			} else {
				if ( expr.top() == '(' && (NOW==')'||NOW=='=') ) {
					//対応する括弧が出てきたので、スタック上の括弧を消す
					expr.pop();
					if ( expr.empty() ) {
						break;
					}
				} else if ( expr.top() == '(' ||
				     NOW == '(' ||
					 ( isstrong(NOW)&&isweak(expr.top()) ) ) {
					//強い演算子はスタックに積んでおく。括弧が積んであるなら、無条件に積む
					expr.push(NOW);
					pos++;
				} else {
					//次の演算子は弱いor同じだから、積んでるものを先に計算してしまおう
					char de = expr.top(); expr.pop();

					int b = num.top(); num.pop();
					int a = num.top(); num.pop();
					int ans;
					switch(de) {
						case '+': ans=a+b; break;
						case '-': ans=a-b; break;
						case '*': ans=a*b; break;
						case '/': ans=a/b; break;
					}
					num.push(ans);
				}
			}
			
		}
		
		printf("%d\n", num.top());
	}
	
}

C++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>

#include<cassert>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

string S;
int cur = 0;//?§£???????§???????

int expression();//????????£?¨?

int digit(){
	// assert(isdigit(S[cur]));
	// cout<<"S[cur]="<<S[cur]<<endl;;
	int n = S[cur++] - '0';
	return n;
}

int number(){
	int n = digit();
	while(cur<S.size() && isdigit(S[cur]))n = n*10+digit();
	return n;
}

int factor(){
	if(S[cur]!='(')return number();
	cur++;
	int n=expression();
	// assert(S[cur++]==')');
	return n;
}

int term(){
	int a = factor();
	while(cur<S.size() && (S[cur]=='*' || S[cur]=='/')){
		char op = S[cur++];
		int b = factor();
		if(op=='*')a*=b;else a/=b;
	}
	return a;
}

int expression() {
	int a = term();
	while (cur<S.size() && (S[cur] == '+' || S[cur] == '-')) { // ?¶???????????????????????¶???????
		char op = S[cur++];
		int b = term();
		if (op == '+')a+=b;else a-=b;
	}
	return a;
}

int main(){
	int N;
	cin>>N;
	rep(i,N){
		cur=0;
		cin>>S;
		S.resize(S.size()-1);
		cout<<expression()<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int isOP(char z){
  if(z=='+')return mod+1;
  if(z=='-')return mod+2;
  if(z=='*')return mod+3;
  if(z=='/')return mod+4;
  return 0;
}
int solve(string s){
  queue<int> Q;
  int cnt=0,i=0;
  bool done=false;
  while(i<s.size()){
    
    if('0'<=s[i]&&s[i]<='9'){
      cnt*=10;
      cnt+=s[i]-'0';
      done=true;
    }
    else{
      if(done)Q.push(cnt);
      done=false;
      cnt=0;
    }
    
    if(s[i]=='('){
      int pnt=0,tnt=1;
      for(int j=i+1;j<s.size();j++){
	if(s[j]=='(')tnt++;
	if(s[j]==')')tnt--;
	if(tnt==0){pnt=j;break;}
      }
      Q.push(solve(s.substr(i+1,pnt-i-1)));
      i=pnt+1;continue;
    }
    
    int tmp=isOP(s[i]);
    if(tmp>0)Q.push(tmp);
    
    i++;
  }
  if(done)Q.push(cnt);
  
  queue<int> R;
  int x;
  while(!Q.empty()){
    int a=Q.front();Q.pop();
    if(a==mod+1||a==mod+2){
      R.push(x);
      R.push(a);
    }
    if(a==mod+3){
      int b=Q.front();Q.pop();
      x*=b;
    }
    if(a==mod+4){
      int b=Q.front();Q.pop();
      x/=b;
    }
    if(a<mod) x=a;
  }
  R.push(x);
  
  x=0;
  while(!R.empty()){
    int a=R.front();R.pop();
    if(a==mod+1){
      int b=R.front();R.pop();
      x+=b;
    }
    if(a==mod+2){
      int b=R.front();R.pop();
      x-=b;
    }
    if(a<mod) x=a;
  }
  return x;
}

int main(){
  int n;cin>>n;
  lol(i,n){
    string s;
    cin>>s;
    s.pop_back();
    cout<<solve(s)<<endl;
  }
  return 0;
}

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(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=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+='=';
	  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++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int isOP(char z){
  if(z=='+')return mod+1;
  if(z=='-')return mod+2;
  if(z=='*')return mod+3;
  if(z=='/')return mod+4;
  return 0;
}
int solve(string s){
  queue<int> Q;
  int cnt=0,i=0;
  bool done=false;
  while(i<s.size()){
    
    if('0'<=s[i]&&s[i]<='9'){
      cnt*=10;
      cnt+=s[i]-'0';
      done=true;
    }
    else{
      if(done)Q.push(cnt);
      done=false;
      cnt=0;
    }
    
    if(s[i]=='('){
      int pnt=0,tnt=1;
      for(int j=i+1;j<s.size();j++){
	if(s[j]=='(')tnt++;
	if(s[j]==')')tnt--;
	if(tnt==0){pnt=j;break;}
      }
      Q.push(solve(s.substr(i+1,pnt-i-1)));
      i=pnt+1;continue;
    }
    
    int tmp=isOP(s[i]);
    if(tmp>0)Q.push(tmp);
    
    i++;
  }
  if(done)Q.push(cnt);
  
  queue<int> R;
  int x;
  while(!Q.empty()){
    int a=Q.front();Q.pop();
    if(a==mod+1||a==mod+2){
      R.push(x);
      R.push(a);
    }
    if(a==mod+3){
      int b=Q.front();Q.pop();
      x*=b;
    }
    if(a==mod+4){
      int b=Q.front();Q.pop();
      x/=b;
    }
    if(a<mod) x=a;
  }
  R.push(x);
  
  x=0;
  while(!R.empty()){
    int a=R.front();R.pop();
    if(a==mod+1){
      int b=R.front();R.pop();
      x+=b;
    }
    if(a==mod+2){
      int b=R.front();R.pop();
      x-=b;
    }
    if(a<mod) x=a;
  }
  return x;
}

int main(){
  int n;cin>>n;
  lol(i,n){
    string s;
    cin>>s;
    s=s.substr(0,s.size()-1);
    cout<<solve(s)<<endl;
  }
  return 0;
}