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<cstdio>
#include<cassert>
using namespace std;
string S;
int cur=0;
int factor();
bool isdigit();
int number();
int term();
int expression();
int main(){
  int n;
  cin>>n;
  while(n--){
    cin>>S;
    cur=0;
    cout<<expression()<<endl;
  }
}

bool isdigit(){
  return '0'<=S[cur]&&S[cur]<='9';
}
int digit(){
  assert(isdigit());
  int ret=(int)(S[cur]-'0');
  cur++;
  return ret;
}
int number(){
  int ret=1;
  while(!isdigit()){
    ret=(S[cur]=='-')?-1:1;
    cur++;
  }
  ret*=digit();
  while(isdigit()){
    ret=ret*10+digit();
  }
  return ret;
}

int factor(){
  int ret=0;
  if(S[cur]=='('){
    cur++;
    ret=expression();
    cur++;//')'
  }else{
    ret=number();
  }
  return ret;
}
int term(){
  int ans=factor();
  while(cur<(int)S.size()-1&&S[cur]!='+'&&S[cur]!='-'&&S[cur]!=')'){
    char op=S[cur];
    cur++;
    int right=factor();
    //cout<<"TERMop=="<<op<<" "<<right<<endl;
    switch(op){
    case '*':
      ans*=right;
      break;
    case '/':
      ans/=right;
      break;
    default ://///
      break;
    } 
  }
  return ans;
}
int expression(){
  int ans=term();
  while(cur<(int)S.size()-1&&S[cur]!=')'){
    char op=S[cur];
    cur++;
    int right=term();
    //cout<<"EXop=="<<op<<" "<<right<<endl;
    switch(op){
    case '+':
      ans+=right;
      break;
    case '-':
      ans-=right;
      break;
    default ://///
      break;
    } 
  }
  return ans;
}

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

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

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

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

        State begin = s.begin();
        int ans = expression(begin);
        cout << ans << endl;
    }

    return 0;
}

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;
}

int term(State &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 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);
    }
}

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

map<char,int> order;
string S; size_t cur=0;
stack<int> num;
stack<char> op;

int digit(){
	int n=S[cur++]-'0';
	return n;
}

int number(){
	int n=digit();
	while(isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

void calc(){
	int b=num.top();num.pop();
	int a=num.top();num.pop();
	char o=op.top();op.pop();
	int c;
	switch(o){
		case '+' :
			c=a+b;
			break;
		case '-' :
			c=a-b;
			break;
		case '*' :
			c=a*b;
			break;
		case '/' :
			c=a/b;
			break;
		default :
			break;
	}
	num.push(c);
	return ;
}

int exp(){
	int smax=S.size();
	while(cur < smax-1){
		//cout << cur << endl;
		if(isdigit(S[cur])){
			int a=number();
			num.push(a);
		}else if(!op.empty()&& order[S[cur]] > order[op.top()]){ //計算順序については改善の余地あり (　は最小に
			calc();
			op.push(S[cur++]);
		}else if(S[cur] == ')' ){
			while(!op.empty()&&op.top()!='(')
				calc();
			//cout << num.top() << endl;
			op.pop();cur++;
		}else{//ひとまず終了　演算記号のチェックも入れる
			op.push(S[cur++]);
		}
	}
	//cout << op.top() << endl;
	while(!op.empty())
		calc();
	return num.top();
}

int main(void){
	order['+']=2;
	order['-']=2;
	order['*']=1;
	order['/']=1;
	//cout << order['('] << endl;
             int nu;
             cin >> nu;
	while(nu--){
		cin >> S;
		cout << exp() << endl;
	}
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int64 exp(string&, int32&);
int64 term(string&, int32&);
int64 fact(string&, int32&);
int64 number(string&, int32&);

int64 exp(string& s, int32& p){
	int64 ret = term(s, p);
	while(p < s.size()){
		if(s[p] == '+'){
			p++;
			ret += term(s, p);
		}else if(s[p] == '-'){
			p++;
			ret -= term(s, p);
		}else{
			break;
		}
	}
	return ret;
}

int64 term(string& s, int32& p){
	int64 ret = number(s, p);
	while(p < s.size()){
		if(s[p] == '*'){
			p++;
			ret *= fact(s, p);
		}else if(s[p] == '/'){
			p++;
			ret /= fact(s, p);
		}else{
			break;
		}
	}
	return ret;
}

int64 fact(string& s, int32& p){
	int64 ret = 0;
	if(s[p] == '('){
		p++;
		ret = exp(s, p);
		p++;
	}else{
		ret = number(s, p);
	}
	return ret;
}

int64 number(string& s, int32& p){
	int64 ret = 0;
	while(isdigit(s[p])){
		ret = ret*10+s[p]-'0';
		p++;
	}
	return ret;
}
int main(void){
	int32 N;
	cin >> N;

	REP(i, N){
		string s;
		int32 p = 0;
		cin >> s;
		cout << exp(s, p) << endl;
	}
}

C++: #include <cassert>
#include<iostream>
#include <cctype>

using namespace std;

#if 0

08-182020の方のものを参照。termの書き換えがわからなかった。

#endif

string S;
size_t cur = 0; // 解析開始位置cursor の略記

// 1 文字読んでcur を進める
// 意味:次のreadchar では、次の文字を読む
char readchar() {
	assert(cur < S.size());
	char ret = S[cur];
	cur += 1;
	return ret;
	// return S[cur++]; と一行で書くこともできる
}
char peek() { // 1 文字読むがcur を進めない
	assert(cur < S.size());
	return S[cur];
}


int factorial(int n) {
	assert(n > 0); // (*)
	if (n == 1) return 1;
	return n * factorial(n-1);
}

int digit() {
	//assert(isdigit(peek())); // S[cur] が数字であることを確認
	int n = readchar() - '0'; // ’0’ を0 に変換
	return n;
}

int number() {
	int n = digit();
	while (cur < S.size() && isdigit(peek())) // 次も数字か1 文字先読
		n = n*10 + digit();
	return n;
}
int expression(); // 前方宣言
int factor() {
	if (peek() != '(') return number();
	cur += 1;
	int n = expression();
	assert(peek() == ')');
	cur += 1;
	return n;
}

int term() {
	int a = factor();
	while (cur < S.size()&& (peek() == '*' || peek() == '/')) {
		char op = readchar();
		int b = factor();
		if (op == '*') a *= b; else a /= b;
	}
	return a;
}

int expression() {
	int a = term();
	while ((cur < S.size())&& (peek() == '+' || peek() == '-')) {
		char op = readchar();
		int b = term();
		if (op == '+') a += b; else a -= b;
	}
	return a;
}



int parse(){
	return expression();
}

int main() {
	//int a = parse();
	//cout << a << endl;
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cur = 0;
		cin >> S;
		S.resize(S.size()-1); // 最後の=を無視
		cout << expression() << endl;
	}
}