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<iostream>
#include<queue>
#include<string>
#include<cctype>
#include<cassert>
using namespace std;

//????¨???????????¶????????????¨???????????????
class CAL{
private:
  string m_str;
  size_t m_cur;
  int digit();
  int number();
  int term();
  int expression();
  int factor();
  int calterm();
public:
  CAL(string str);
  int cal();
};

//?????????????????????
CAL::CAL(string str)
{
  m_str = str;
  m_cur = 0;
  m_str.resize(m_str.size() - 1);
}

//??????????????°????????°????????????
int CAL::digit()
{
  assert(isdigit(m_str[m_cur]));
  int n = m_str[m_cur++] - '0';
  return n;
}

//??°??????????????¨?????¨???????????°??????????????????
int CAL::number()
{
  int n = digit();
  while(m_cur < m_str.size() && isdigit(m_str[m_cur]))
    n = n*10 + digit();
  return n;
}

//???????????¨?????????????°???\
int CAL::term()
{
  int a = number();
  while(m_cur < m_str.size() && (m_str[m_cur] == '*' || m_str[m_cur] == '/')){
    char op = m_str[m_cur++];
    int b = number();
    if(op == '*') a *= b; else if(op == '/') a /= b;
  }
  return a;
}

//??¬??§???????????????????????????
int CAL::expression()
{
  int a = term();
  while(m_cur < m_str.size() && (m_str[m_cur] == '+' || m_str[m_cur] == '-')){
    char op = m_str[m_cur++];
    int b = term();
    if(op == '+') a += b; else if(op == '-') a -= b;
  }
  return a;
}

//??¬??§???????????????????????°?????¨?????????????????????number()??????????????????
int CAL::factor()
{
  if(m_str[m_cur] != '(') return number();
  m_cur += 1;
  int n = expression();
  assert(m_str[m_cur] == ')');
  m_cur += 1;
  return n;
}

//??¬??§????????£?????´?????????????????¨?????????????°???\
int CAL::calterm()
{
  int a = factor();
  while(m_cur < m_str.size() && (m_str[m_cur] == '*' || m_str[m_cur] == '/')){
    char op = m_str[m_cur++];
    int b = factor();
    if(op == '*') a *= b; else if(op == '/') a /= b;
  }
  return a;
}

//??¬??§????????£?????´???????????????????????????????¨????
int CAL::cal()
{
  int a = calterm();
  while(m_cur < m_str.size() && (m_str[m_cur] == '+' || m_str[m_cur] == '-')){
    char op = m_str[m_cur++];
    int b = calterm();
    if(op == '+') a += b; else if(op == '-') a -= b;
  }
  return a;
}

int main()
{
  int N;
  cin >> N;
  queue<int> answer;
  string str;
  for(int i = 0; i < N; ++i){
    cin >> str;
    CAL a(str);
    answer.push(a.cal());
  }
  while(!answer.empty()){
    cout << answer.front() << endl;
    answer.pop();
  }
}

C++: #include <iostream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <sstream>
using namespace std;
int hoge(string a)
{
	if(a=="(")return -1;
	if(a=="*"||a=="/")return 1;
	return 0;
}

long long calc(long long a,long long b,string str)
{
	if(str=="+")return a+b;
	if(str=="-")return a-b;
	if(str=="/")return a/b;
	if(str=="*")return a*b;
	
}

int main()
{
	int n;cin>>n;
	while(n--)
	{
		string str;cin>>str;
		stringstream ss;
		for(int i=0;i<str.size()-1;i++)
		{
			if(str[i]=='+'||str[i]=='-'||str[i]=='/'||str[i]=='*'||str[i]=='('||str[i]==')')ss<<" "<<str[i]<<" ";
			else ss<<str[i];
		}
		
		vector<string> v;
		stack<string> st;
		while(getline(ss,str,' '))
		{
			if(str=="")continue;
			if(str=="+"||str=="-"||str=="/"||str=="*")
			{
				while(!st.empty()&&hoge(st.top())>hoge(str))
				{
					v.push_back(st.top());
					st.pop();
				}
				st.push(str);
			}
			else if(str==")")
			{
				while(st.top()!="(")
				{
					v.push_back(st.top());
					st.pop();
				}
				st.pop();
			}
			else if(str=="(")st.push(str);
			else v.push_back(str);
		}
		while(!st.empty())
		{
			
			v.push_back(st.top());
			st.pop();
		}
		stack<long long> k;
		for(int i=0;i<v.size();i++)
		{
			
			if(v[i]=="+"||v[i]=="-"||v[i]=="/"||v[i]=="*")
			{
				long long A,B;
				B=k.top();k.pop();
				A=k.top();k.pop();
				k.push(calc(A,B,v[i]));
			}
			else
			{
				k.push(atol(v[i].c_str()));
			}
		}
				cout<<k.top()<<endl;
	}
	
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

class Parser
{
public:
	string exp;
	int p;
	double expression (void );
	double term (void );
	double factor (void );
private:
	double stod (string );
};

double Parser::stod (string str )
{
	stringstream ss (str );
	double res;
	
	ss >> res;

	return res;
}

double Parser::expression (void)
{
	double value = term ();

	while (exp[p] == '+' || exp[p] == '-' ){
		if (exp[p] == '+' ){
			++p; value += term();
		}else{
			++p; value -= term();
		} // end if
	} // end while

	return value;
}

double Parser::term (void)
{
	double value = factor();

	while (exp[p] == '*' || exp[p] == '/' ){
		if (exp[p] == '*'){
			++p; value *= factor();
		}else{
			++p; value /= factor();
		} // end if
	} // end while

	return value;
}

double Parser::factor (void)
{
	double value = 0;
	string res = "";

	if (exp[p] == '('){
		++p; value = expression(); ++p;
	}else{
		while (isdigit(exp[p]) || exp[p] == '.' ){
			res += exp[p];
//			value = value * 10 + exp[p] - '0';
			++p;
		} // end while
		value = stod (res );
	} // end if
	
	return value;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.sc", "r", stdin);

	Parser parser;
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i;
	for (i = 0; i < n; ++i){
		getline (cin, str );
		parser.exp = str;
		parser.p = 0;
		cout << (int)(parser.expression()) << endl;
	} // end loop
		
	return 0;
}