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"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

class Parser {
public:
	using Iter = string::const_iterator;
	Iter it;
	Parser(Iter it) :it(it) {}
	void cmp(char expected) { assert(*it == expected); }
	/*
	EBNF
	???=???,["+"|"-",???] | "(",???,["+"|"-",???],")"
	???=c,["*"|"/",???]
	c=??°|"(",???,")"
	*/
	int a() {
		int ret = b();
		if (*it == '+') {
			it++;
			ret += a();
		}
		else if (*it == '-') {
			it++;
			ret -= a();
		}
		return ret;
	}
	int b() {
		int ret = c();
		if (*it == '*') {
			it++;
			ret *= b();
		}
		else if (*it == '/') {
			it++;
			ret /= b();
		}
		return ret;
	}
	int c() {
		int ret;
		if (*it == '(') {
			it++;
			ret = a();
			cmp(')');
			it++;
		}
		else ret = integer();
		return ret;
	}
	int integer() {
		int ret = 0;
		while (isdigit(*it)) {
			ret *= 10;
			ret += *it - '0';
			it++;
		}
		return ret;
	}
};

signed main() {
	int n; cin >> n; cin.ignore();
	for (string s; getline(cin, s) && s != "$"; ) {
		s += "$";
		Parser P(s.begin());
		cout << P.a() << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cctype>
#include <string>
#include <cassert>
enum class Type : char {
	Num, Pos = '+', Neg = '-', Mul = '*', Div = '/', LP = '(', RP = ')', End = '='
};

struct Token {
	Type type;
	int num;
};

class Expression {
public:
	Expression(std::istream *s) :is{ s } {};
	Token &current() {
		return _current;
	}
	Token get() {
		char c;
		if (!((*is).get(c))) return _current = { Type::End };
		switch (c) {
		case '+':
		case '-':
		case '*':
		case '/':
		case '(':
		case ')':return _current = { static_cast<Type>(c) }; break;
		case '=':
		case '\n': return _current = { Type::End }; break;
		default:
			if (isdigit(c)) {
				std::string str;
				str.push_back(c);
				while ((*is).get(c)) {
					if (isdigit(c)) {
						str.push_back(c);
					}
					else {
						(*is).putback(c);
						return _current = { Type::Num, std::stoi(str) };
					}
				}
				return _current = { Type::Num, std::stoi(str) };
			}
			else throw;
		}
	}
private:
	std::istream *is;
	Token _current{ Type::End };
};
int cul_sub_express(Expression &, const bool &);
int cul_value(Expression &exp, const bool &use_get) {
	if (use_get) exp.get(); //?????????????£???°???
	int mid;
	switch (exp.current().type) {
	case Type::Num: return exp.current().num;
	case Type::Neg: 
		mid = cul_sub_express(exp, true);
		return exp.current().num = -mid;
	case Type::LP:
		mid = cul_sub_express(exp, true);
		exp.current() = { Type::Num, mid };
		return mid;
	}
}
int cul_pri_express(Expression &exp, const bool &use_get) {
	if (use_get) exp.get();
	auto left = cul_value(exp, false);
	switch (exp.get().type) {
	case Type::Mul:
		left *= cul_value(exp, true);
		exp.current().num = left;
		return cul_pri_express(exp, false);
	case Type::Div:
		left /= cul_value(exp, true);
		exp.current().num = left;
		return cul_pri_express(exp, false);
	default:
		return left;
	}
}
int cul_sub_express(Expression &exp, const bool &use_get) {
	if (use_get) exp.get();
	auto left = cul_pri_express(exp, false);
	switch (exp.current().type) {
	case Type::Pos:
		left += cul_pri_express(exp, true);
		return exp.current().num = left;
	case Type::Neg:
		left -= cul_pri_express(exp, true);
		return exp.current().num = left;
	default:
		return left;
	}
}
int execute(Expression &exp) {
	return cul_sub_express(exp, true);
}
int main() {
	Expression express(&std::cin);
	std::cout << execute(express) << std::endl;
	return 0;
}

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

int p;
string exp;

int term();
int expression();
int factor();


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


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

	return value;
}

int factor(){
	int value=0;
	if(exp[p]=='('){
		value=expression();
		p++;
	}
	else{
		while(isdigit(exp[p])){
			value=value*10+exp[p++]-'0';
		}
	}
	return value;
}



int main()
{
	int i,c;
	cin>>c;
	for(i=0;i<c;i++){
		cin>>exp;
		p=0;
		cout<<expression()<<"\n";
		}
	cout<<"\n";
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll number(State &);
ll factor(State &);
ll term(State &);
ll expr(State &);

ll number(State &begin) {
	ll ret = 0;
	while (isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}
ll factor(State &begin) {
	if (*begin == '(') {
		begin++;
		ll ret = expr(begin);
		begin++;
		return ret;
	} else {
		return number(begin);
	}
}
ll term(State &begin) {
	ll ret = factor(begin);
	while (1) {
		if (*begin == '*') {
			begin++;
			ret *= factor(begin);
		} else if (*begin == '/') {
			begin++;
			ret /= factor(begin);
		} else {
			break;
		}
	}
	return ret;
}
ll expr(State &begin) {
	ll ret = term(begin);
	while (1) {
		if (*begin == '+') {
			begin++;
			ret += term(begin);
		} else if (*begin == '-') {
			begin++;
			ret -= term(begin);
		} else {
			break;
		}
	}
	return ret;
}

int main() {
	ll n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		string s;
		getline(cin, s);

		State begin = s.begin();
		dump(expr(begin));
	}
	return 0;
}