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 <bits/stdc++.h>
#include <cctype>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e15;
typedef pair<ll,ll> P;
typedef string::const_iterator State;
class ParseError {};
int expression(State &begin);
int term(State &begin);
int number(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 expression(State &begin){
    int ret = term(begin);
    for(;;){
        if (*begin == '+'){
            begin++;
            ret += term(begin);
        }
        else if (*begin == '-'){
            begin++;
            ret -= term(begin);
        }
        else{
            break;
        }
    }
    return ret;
}
int factor(State &begin){
    if (*begin == '('){
        begin++;
        int ret = expression(begin);
        begin++;
        return ret;
    }
    else{
        return number(begin);
    }
}
int term(State &begin){
    int ret = factor(begin);
    for(;;){
        if (*begin == '*'){
            begin++;
            ret *= factor(begin);
        }
        else if(*begin == '/'){
            begin++;
            ret /= factor(begin);
        }
        else{
            break;
        }
    }
    return ret;
}

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

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

inline bool is_all_digit(string &in)
{
	for (auto i : in)
	{
		if (!isdigit(i))
			return false;
	}
	return true;
}
vector<string> split(string in)
{
	vector<string> spl;
	int pos = 0;
	if (in[pos] == '-') 
	{
		pos++;
		while (pos < in.size()) {
			if (isdigit(in[pos])) {
				pos++;
			}
			else {
				break;
			}
		}
		spl.push_back(in.substr(0, pos));
		in.erase(0, pos);
		pos = 0;
	}
	while ( pos < in.size())
	{
		if (!isdigit(in[pos]))
		{
			if (pos != 0)
			{
				spl.push_back(in.substr(0, pos));
				in.erase(0, pos);
				pos = 0;
			}
			else
			{
				if (in[0] == '(')
				{
					int cnt = 1;
					int r_pos = 1;
					for (r_pos = 1; r_pos < in.size(); r_pos++)
					{
						if (in[r_pos] == '(')
							cnt++;
						if (in[r_pos] == ')')
							cnt--;
						if (cnt == 0)
							break;
					}
					spl.push_back(in.substr(pos + 1, r_pos - 0 - 1));
					in.erase(0, r_pos + 1);
					pos = 0;
					continue;
				}
				else if (in[0] == '+' || in[0] == '-' || in[0] == '*' || in[0] == '/')
				{
					spl.push_back(in.substr(0, 1));
					in.erase(0, 1);
					pos = 0;
				}
			}
		}
		else {
			pos++;
		}
	}
	if (in.size() != 0) spl.push_back(in);
	return spl;
}
int cal(string &in_str) {
	auto in = split(in_str);
	while (in.size() == 1 && !is_all_digit(in[0])) {
		in = split(in[0]);
	}
	while (in.size() != 1) {
		auto pos = in.begin();
		while (pos != in.end()) 
		{
			if (*pos == "*") {
				pos--;
				*pos = to_string(cal(*pos)*cal(*(pos + 2)));
				in.erase(pos+1 , pos + 3);
			}
			else if (*pos == "/") {
				pos--;
				*pos = to_string(cal(*pos)/cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if (pos != in.end()) pos++;
		}
		pos = in.begin();
		while (pos != in.end()) {
			if (*pos == "+") {
				pos--;
				*pos = to_string(cal(*pos)+cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			else if (*pos == "-") {
				pos--;
				*pos = to_string(cal(*pos) - cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if(pos != in.end()) pos++;
		}
	}
	return(stoi(in[0]));
}
int main()
{
	
	int n;
	cin >> n;
	while (n--) {
		cin >> input;
		input.erase(input.end() - 1);
		cout << cal(input) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cctype>
using namespace std;
typedef string::const_iterator State;

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

int main(void){
  int N;
  cin >> N;
  cin.ignore();
  for(int i = 0; i < N; i++){
    string Expression;
    getline(cin, Expression);

    State begin = Expression.begin();
    int ans = expression(begin);
    cout << ans << endl;
  }
  return 0;
}

int number(State &begin){
  int ret = 0;

  while(isdigit(*begin)){
    ret = ret * 10;
    ret = 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){
  int ret = factor(begin);

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

int expression(State &begin){
  int ret = term(begin);

  while(true){
    if(*begin == '+'){
      begin++;
      ret = ret + term(begin);
    }else if(*begin == '-'){
      begin++;
      ret = ret - term(begin);
    }else{
      break;
    }
  }

  return ret;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 100000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
typedef string::const_iterator State;
int expression(State& begin);
int term(State& begin);
int number(State& begin);
int factor(State& begin);
int factor(State& begin) {
	if (*begin == '(') {
		begin++;
		int ret = expression(begin);
		begin++;
	}
	else {
		return number(begin);
	}
}
int expression(State& begin) {
	int ret = term(begin);
	for (;;) {
		if (*begin == '+') {
			begin++;
			ret += term(begin);
		}
		else if (*begin == '-') {
			begin++;
			ret -= term(begin);
		}
		else break;
	}
	return ret;
}
int term(State& begin) {
	int ret = factor(begin);
	for (;;) {
		if (*begin == '*') {
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/') {
			begin++;
			ret /= factor(begin);
		}
		else {
			break;
		}
	}
	return ret;
}
int number(State& begin) {
	int ret = 0;
	while (isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}
int main() {
	long long n;
	cin >> n;
	REP(imt, n) {
		string s;
		cin >> s;
		State begin = s.begin();
		cout << expression(begin) << endl;
	}
	return 0;
}