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

int exp();
int term();
int factor();
string str;
int p;

int factor(){
  int val=0;
  while(str[p]>='0' && str[p]<='9'){ 
    val*=10;
    val+=str[p]-'0';
    p++;
  }
  
  if(str[p]=='('){
    p++;
    val=exp();
  }
  if(str[p]==')') p++;
  return val;
}

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

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


int main(){
  int n;
  
  cin>>n;
  for(int i=0;i<n;i++){
    p=0;
    cin>>str;
    cout<<exp()<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cassert>
using namespace std;
string S;
size_t cur = 0;

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

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

int expression();
int factor() {       //Factor := '(' Expression ')' | Number
    if(S[cur] != '(') return number();
    cur++;
    int n = expression();
    assert(S[cur] == ')');
    cur++;
    return n;
}

int term() {       //Term := Factor { ('*'|'/') Factor }
    int a = factor();
    while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
        char op = S[cur++];
        int b = factor();
        if(op =='*') { a *= b; } else { a /= b; }
    }
    return a;
}

int expression() {       //Expression := Term { ('+'|'-') Term}
    int a = term();
    while(cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
        char op = S[cur++];
        int b = term();
        if(op == '+') { a += b; } else { a -= b;}
    }
    return a;
}

int main() {
    int N;
    cin >> N;
    for(int i=0; i<N; i++) {
        cur = 0;
        cin >> S;
        S.resize(S.size() - 1);
        cout << expression() << endl;
    }
}

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

int calculate( int a, int b, char c )
{
    if( c == '+' )
        return a + b;
    else if( c == '-' )
        return a - b;
    else if( c == '*' )
        return a * b;
    else if( c == '/' )
        return a / b;
    else
        return a;
}

int getMax( int a, int b )
{
    return a > b ? a : b;
}

int main()
{
    int n;
    string s;
    vector<int> d, p;
    vector<char> c;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> s;

        int a = 0, b = 0;
        for( int j = 0; j < s.size(); j++ )
        {
            if( '0' <= s[j] && s[j] <= '9' )
                a = a * 10 + s[j] - '0';
            else if( '0' <= s[j-1] && s[j-1] <= '9' )
            {
                d.push_back(a);
                a = 0;
            }
            else;
            
            if( s[j] == '+' || s[j] == '-' )
            {
                c.push_back(s[j]);
                p.push_back(b+1);
            }
            else if( s[j] == '*' || s[j] == '/' )
            {
                c.push_back(s[j]);
                p.push_back(b+2);
            }
            else if( s[j] == '(' )
                b += 10;
            else if( s[j] == ')' )
                b -= 10;
            else;
        }

        int cnt = c.size();
        while( cnt-- )
        {    
            int m = 0;
            for( int j = 0; j < p.size(); j++ )
                m = max( m, p[j] );

            for( int j = 0; j < p.size(); j++ )
                if( p[j] == m )
                {
                    p[j] = 0;
                    d[j] = calculate( d[j], d[j+1], c[j] );
                    for( int k = j; k < c.size() - 1; k++ )
                    {
                        c[k] = c[k+1];
                        p[k] = p[k+1];
                        p[k+1] = 0;
                    }
                    for( int k = j + 1; k < d.size() - 1; k++ )
                        d[k] = d[k+1];
                    break;
                }
        }
        cout << d[0] << endl;
        d.clear();
        c.clear();
        p.clear();
    }
    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int solve(string& s, int& i)
{
    int a = 0;
    int b = 0;
    char prev = '+';
    for(;;){
        int x = 0;
        if(s[i] == '('){
            ++ i;
            x += solve(s, i);
            ++ i;
        }else{
            while('0' <= s[i] && s[i] <= '9'){
                x *= 10;
                x += s[i] - '0';
                ++ i;
            }
        }

        if(prev == '+'){
            a += b;
            b = x;
        }else if(prev == '-'){
            a += b;
            b = -x;
        }else if(prev == '*'){
            b *= x;
        }else{
            b /= x;
        }

        if(s[i] == ')' || s[i] == '=')
            break;

        prev = s[i];
        ++ i;
    }

    return a + b;
}

int main()
{
    int n;
    cin >> n;

    while(--n >= 0){
        string s;
        cin >> s;
        int i = 0;
        cout << solve(s, i) << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

typedef string::const_iterator State;

class ParseError{};

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
int number(State &begin);
int term(State &begin);
int expression(State &begin);
int expression(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){
    int ret = factor(begin);
    for(;;){
        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);

    for(;;){
        if (*begin == '+'){
            begin++;
            ret += term(begin);
        } else if(*begin == '-'){
            begin++;
            ret -= term(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;
    }
}