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('0'<=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 <iostream>
#include <string>
using namespace std;

string str;
int pos;

int exp();
int term();
int factor();
int henkan(string);
int ruijou(int);

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    str="";
    getchar();
    while(1){
      char temp;
      cin >> temp;
      if(temp=='=') break;
      str+=temp;
    }
    
    pos=0;
    int ans=0;
    ans=exp();

    cout << ans << endl;
  }
  return 0;
}

int exp(){
  int x=term();
  
  while(str[pos]=='+' || str[pos]=='-'){
    char op=str[pos];
    pos++;
    if(op=='+'){
      x+=term();
    }
    else{
      x-=term();
    }
  }
  return x;
}

int term(){
  int x=factor();
  while(str[pos]=='*' || str[pos]=='/'){
    char op=str[pos];
    pos++;
    if(op=='*') x*=factor();
    else x/=factor();
  }
  return x;
}

int factor(){
  int x;

  if(str[pos]=='('){
    pos++;
    x=exp();
    pos++;
  }
  else{
    string number="";
    int i=pos;
    while(str[i]>='0' && str[i]<='9'){
      number+=str[i];
      i++;
    }
    pos=i;
    x=henkan(number);
  }
  
  return x;
}

int henkan(string number){
  int size=number.size();
  int sum=0;
  
  for(int i=0;i<size;i++){
    sum+=(number[i]-'0')*ruijou(size-i-1);
  }
  return sum;
}

int ruijou(int n){
  int sum=1;
  
  for(int i=0;i<n;i++){
    sum*=10;
  }
  
  return sum;
}

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


class Parsing{
private:
  string parse;
  int pos;
public:

  Parsing(string s){
    parse = s;
    pos = 0;
  }

  int expression(){
    int p = term();
    while(parse[pos] == '+' || parse[pos] == '-'){
      if(parse[pos] == '+')pos++,p+=term();
      else pos++,p-=term();
    }
    return p;
  }

  int term(){
    int p = fact();
    while(parse[pos] == '*' || parse[pos] == '/'){
      if(parse[pos] == '*')pos++,p *= term();
      else pos++,p /= term();
    }
    return p;
  }

  int fact(){
    if(parse[pos] == '('){
      pos++;
      int p = expression();
      pos++;
      return p;
    }else{
      int p = 0;
      while('0' <= parse[pos] && parse[pos] <= '9'){
	p *= 10;
	p += parse[pos]-'0';
	pos++;
      }
      return p;
    }
  }


};








int main(){
  string s;
  int N;
  cin >> N;
  while(N-- > 0){
    cin >> s;
    Parsing par = Parsing(s.substr(0,s.length()-1));
    cout << par.expression() << endl;
  }
  return 0;
}

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

template<typename T>
struct Parser {
	using itr = string::const_iterator;
	itr now;
	T ans;
	const struct ex {
		vector<char> _012;
		ex() {
			_012.resize(10);
			for(int i = 0; i < 10; ++i) {
				_012[i] = (char)('0' + i);
			}
		}
	} ex;
	Parser(const string &s) {
		now = s.begin();
		ans = expr(now);
	}
	T expr(itr &now) {
		T ret = term(now);
		while(true) {
			if(*now == '+') {
				next(now, '+');
				ret += term(now);
			}else if(*now == '-') {
				next(now, '-');
				ret -= term(now);
			} else {
				return ret;
			}
		}
	}
	T term(itr &now) {
		T ret = fact(now);
		while(true) {
			if(*now == '*') {
				next(now, '*');
				ret *= fact(now);
			}else if(*now == '/') {
				next(now, '/');
				ret /= fact(now);
			} else {
				return ret;
			}
		}
	}
	T fact(itr &now) {
		if(*now == '(') {
			next(now, '(');
			T ret = expr(now);
			next(now, ')');
			return ret;
		} else {
			return numb(now);
		}
	}
	T numb(itr &now) {
		T ret = 0;
		while('0' <= *now and *now <= '9') {
			ret *= 10;
			ret += (T)(*now - '0');
			next(now, ex._012);
		}
		return ret;
	}
	void next(itr &now, const char expected) {
		vector<char> req = {expected};
		next(now, req);
	}
	void next(itr &now, const vector<char> &expected) {
		for(char c : expected) {
			if(*now == c) {
				now++;
				return;
			}
		}
		cerr << *now << "\n";
		for(char c : expected) cerr << c << "\n";
	}
};

int main() {
	int n; cin >> n;
	while(n--) {
		string s; cin >> s;
		Parser<int> parse(s);
		cout << parse.ans << "\n";
	}
	return 0;
}