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<cctype>
#define I int
I E();std::string S;I P,V;I T(){for(V=0;isdigit(S[P]);)V=V*10+S[P++]-48;return S[P]-40?V:!!++P*E()*!!++P;}I F(){I a=T();for(;S[P]==42|S[P]==47;)a=S[P++]-47?a*=T():a/=T();return a;}I E(){I a=F();for(;S[P]==43|S[P]==45;)a+=-(S[P++]==45)*F();return a;}main(){for(std::cin>>P;std::cin>>S;printf("%d\n",E()))S[S.size()-1]=P=0;}

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

using namespace std;

string calc;
int cur;
int digit();
int number();
int expression();
int term();
int factor();

int main(){
  int num,i;
  cin >> num;
  for (i = 0; i < num; ++i){
    cin >> calc;
    calc.resize(calc.size()-1);
    cur = 0;

    cout << calc << endl;
    cout << expression() << endl;
  }
}

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

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

int expression(){
  int sum = term(); 
  while((cur < calc.size())&&(calc[cur]=='+'||calc[cur]=='-')){
    char op = calc[cur];
    cur++; // will look at the next num after op
    int b = term();
    if(op == '+'){
      sum += b;
    }else{
      sum -= b;
    }
  }
  return sum;
}

int term(){
  int a = factor();
  while((cur < calc.size())&&(calc[cur]=='*'||calc[cur]=='/')){
    char op = calc[cur];
    cur++; // will look at the next num after op
    int b = factor();
    if(op == '*'){
      a *= b;
    }else{
      a /= b;
    }
  }
  return a;
}

int factor(){
  if(calc[cur] != '('){
    return number();
  }else{
    cur++;
    int n = expression();
    assert(calc[cur] == ')');
    cur++;
    return n;
  }
}

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

using namespace std;


// ?????????????§?????§£???????????????????????¨???????????????
class MathExpress
{
private:
    string m_express;
    size_t m_cur = 0;

public:
    MathExpress(string str) : m_express(str) 
    {
        m_express.resize(m_express.size() - 1);
    }

    int digit(); // ???????????°???
    int number(); // ??°??????????????°????????´???
    int term();
    int factor(); 
    int expression();
};


int MathExpress::digit()
{
    assert(isdigit(m_express.at(m_cur)));

    int n = m_express.at(m_cur) - '0';

    m_cur += 1;

    //cout << "digit: " << n << endl;

    return n;
}


int MathExpress::number()
{
    int num = digit();

    while ( m_cur < m_express.size() && isdigit(m_express.at(m_cur)) )
    {
        num = num * 10 + digit();
    }

    //cout << "number: " << num << endl;

    return num;
}


int MathExpress::term()
{
    int left = factor();

    while (m_cur < m_express.size() 
         && (m_express.at(m_cur) == '*' || m_express.at(m_cur) == '/'))
    {
        char op = m_express.at(m_cur++);

        //cout << op << endl;

        int right = number();

        switch (op) {
            case '*':
                left *= right;
                break;
            case '/':
                left /= right;
                break;
            default:
                break;
        }

    }

    //cout << "term: " << left << endl;

    return left;
}


int MathExpress::expression()
{
    int left = term();

    while (m_cur < m_express.size() 
         && (m_express.at(m_cur) = '+' || m_express.at(m_cur) == '-'))
    {
        //cout << m_cur << " " << m_express.at(m_cur) << endl;
        char op = m_express.at(m_cur);

        m_cur += 1;

        //cout << op << endl;
        //cout << "hoge" << endl;

        int right = term();

        //cout << "hoge" << endl;

        switch (op) {
            case '+':
                //cout << "hoge" << endl;
                left += right;
                break;
            case '-':
                left -= right;
                break;
            default:
                //cout << "hoge" << endl;
                break;
        }

        //cout << "left : right = " << left << " " << right << endl;
    }

    return left;
}


int MathExpress::factor()
{
    if (m_express.at(m_cur) != '(') return number();

    m_cur += 1;

    int exp = expression();

    assert (m_express.at(m_cur) == ')');

    m_cur += 1;

    return exp;
}


int main()
{
    int data_num;
    
    cin >> data_num;
    
    cin.clear();

    string val; 
    for (int i = 0; i < data_num; ++i) {
        cin >> val;

        MathExpress mathexp(val);
        cout << mathexp.expression() << endl;
    }
    
    return 0;
}