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 <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)
#define big (long long int)(10e9 + 7)

int siki(string &str, int &i);
int kou(string &str, int &i);
int insu(string &str, int &i);
int number(string &str, int &i);

int main(void) {
	int num = 0;
	cin >> num;
	rep(0, num) {
		string str;
		int x = 0;
		cin >> str;
		cout << siki(str, x) << endl;
	}
}

int siki(string &str,int &i) {
	int val1 = kou(str,i);
	while (str[i] == '+' || str[i] == '-') {
		char op = str[i];
		i++;
		int val2 = kou(str, i);
		if (op == '+') {
			val1 = val1 + val2;
		}
		else
		{
			val1 = val1 - val2;
		}
	}
	return val1;
}

int kou(string &str, int &i) {
	int val1 = insu(str, i);
	while (str[i] == '*' || str[i] == '/') {
		char op = str[i];
		i++;
		int val2 = insu(str, i);
		if (op == '*') {
			val1 = val1 * val2;
		}
		else {
			val1 = val1 / val2;
		}
	}
	return val1;
}

int insu(string &str, int &i) {
	int val1 = 0;

	if(str[i] != '(')val1 = number(str, i);
	if(str[i] == '(') {
		i++;
		val1 += siki(str, i);
		i += 1;
	}

	
	
	return val1;
}

int number(string &str, int &i) {
	int val1 = 0;
	if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			 val1 = (int)str[i] - (int)'0';
		i++;
		if (str[i] == '0' || str[i] == '1' || str[i] == '2' || str[i] == '3' || str[i] == '4' || str[i] == '5' || str[i] == '6' || str[i] == '7' || str[i] == '8' || str[i] == '9') {
			val1 = val1 * 10;
			val1 += number(str, i);
		}
	}
	return val1;
}

C++: #include<iostream>
#include<sstream>

using namespace std;

bool isnum(string s){
  for(int i = 0; i < s.length(); i++)
    if('0' > s[i] || s[i] > '9') return false;
  
  return true;
}

int solve(string s){

  if(s[0] == '-') return -1*solve(s.substr(1));
  if(isnum(s)){
    stringstream ss(s);
    int tmp;
    ss >> tmp;
    return tmp;
    
  }else{
    int para = 0;

    for(int i = 0; i < s.length(); i++){
      if(s[i] == '(') para++;
      if(s[i] == ')') para--;

      if((s[i] == '+' || s[i] == '-') && para == 0 && i)
	if(s[i] == '+') return solve(s.substr(0,i))+solve(s.substr(i+1));
	else return solve(s.substr(0,i))-solve(s.substr(i+1));
    }

    para = 0;

    for(int i = 0; i < s.length(); i++){
      if(s[i] == '(') para++;
      if(s[i] == ')') para--;
      
      if((s[i] == '*' || s[i] == '/') && para == 0 && i)
	if(s[i] == '*') return solve(s.substr(0,i))*solve(s.substr(i+1));
	else return solve(s.substr(0,i))/solve(s.substr(i+1));
    }

    if(s[0] == '(' && s[s.length()-1] == ')')
      return solve(s.substr(1,s.length()-2));
  }
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    cout << solve(s.substr(0,s.length()-1)) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <cctype>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

typedef string::const_iterator State;
class ParseError {};

int number(State &begin);
int factor(State &begin);
int term(State &begin);
int factor(State &begin);

// ??°?????????????????????
int number(State &begin) {
    int ret = 0;
    while(isdigit(*begin)) {
        ret *= 10;
        ret += (*begin - '0');
        begin++;
    }
    return ret;
}

// ??¬??§?????°????????????
int factor(State &begin) {
    if(*begin == '(') {
        begin++; // '(' ????£???°???
        int ret = expression(begin);
        begin++; // ')' ????£???°???
        return ret;
    }
    else return number(begin);
}

// ??????????????????????????????
int term(State &begin) {
    // ????????????????????¨????????£????????°??????????????§???????????????
    // begin ?????????????????°?????§???????????????
    int ret = factor(begin);

    while(1) {
        if(*begin == '*') {
            begin++;
            ret *= factor(begin);
        }
        else if(*begin == '/') {
            begin++;
            ret /= factor(begin);
        }
        else break;
    }

    return ret;
}

// ??????????????????????????????
int expression(State &begin) {
    int ret = term(begin);
    while(1) {
        if(*begin == '+') {
            begin++;
            ret += term(begin);
        }
        else if(*begin == '-') {
            begin++;
            ret -= term(begin);
        }
        else break;
    }
    return ret;
}

signed main() {
    int N; cin >> N;
    rep(i,0,N) {
        string s; cin >> s;
        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }
    return 0;
}

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 factor();
public:
  CAL(string str);
  int expression();
};

//?????????????????????
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 = 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;
}

//??¬??§???????????????????????°?????¨?????????????????????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::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;
}

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.expression());
  }
  while(!answer.empty()){
    cout << answer.front() << endl;
    answer.pop();
  }
}