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<string>
#include<cctype>
typedef string::const_iterator State;
class Parse Error{};

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

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

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

  while(isdigit(*begin)){
    ret *= 10;
    ret +=~ *begin -'0';
    begin++;
  }

  return ret;
}

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

  for(;;){
    if(*begin == '*'){
      begin++;
      ret *= factor(begin);
    } else if (*begin =='/'){
      begin++;:
      ret /= factor(begin);
    } else{
      break;
    }
  }

  return ret;
}

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

C++: #include <stdio.h>

char stk[50], psh[50];
int v[50],pri[256], sp, pp;

int calc(char *p) {
  int i;
  char *exp = p;
  for (i = 0; i < 256; i++)
    pri[i] = 3;
  pri['+'] = pri['-'] = 1;
  pri['*'] = pri['/'] = 2;
  pri['('] = 4;
  pri[')'] = 0;
  stk[0] = 0;
  pri[0] = -1;
  sp = pp = 0;
  while (*p != '\0') {
    while (pri[*p] <= pri[stk[sp]] && stk[sp] != '(')
      psh[++pp] = stk[sp--];
    if (*p != ')')
      stk[++sp] = *p;
    else
      sp--;
    p++;
  }
  for (i = sp; i > 0; i--)
    psh[++pp] = stk[i];
  sp = 0;
  for (i = 1; i <= pp; i++) {
    if ('0' <= psh[i] && psh[i] <= '9')
      v[++sp] = psh[i] - '0';
    else {
      switch (psh[i]) {
      case '+':
        v[sp - 1] = v[sp - 1] + v[sp];
        break;
      case '-':
        v[sp - 1] = v[sp - 1] - v[sp];
        break;
      case '*':
        v[sp - 1] = v[sp - 1] * v[sp];
        break;
      case '/':
        v[sp - 1] = v[sp - 1] / v[sp];
        break;
      }
      sp--;
    }
  }
  printf("%d\n",v[1]);
}

int main() {
  int i, j, n;
  char p[50][100];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%s", p[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < 100; j++)
      if (p[i][j] == '=')
        p[i][j] = '\0';
  for (i = 0; i < n; i++)
    calc(p[i]);
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string.h>

#define loop(lp) for(int lp2 = 0; lp2 < lp; lp2 ++) 
#define ascent(i,a,b) for(int i = a; i < b; i ++)

#define pb push_back

#define MAX 10000010

using namespace std;

bool flg[200000];
int  isprime[MAX];

int main() {
  //  vector<int> p1,p2;
  vector<int> p;

  ascent(i, 0, MAX) {
     isprime[i] = 1;
  }
   isprime[0] =  isprime[1] = 0;
  
  int cnt = 0;
  ascent(i, 2, MAX) {
    if(isprime[i]) {
      for(int j = 2*i; j <= MAX; j += i) {
	 isprime[j] = 0;
      }
    }
  }
  
  int N, P;
  while(cin >> N >> P) {
    if(N == -1 && P == -1) break;

    memset(flg, true, sizeof(flg));

    int k = N+1;
    int l = 0;
    p.clear();
    while(l < P) {
      if(isprime[k]) {
	p.pb(k);
	l ++;
      }
      k ++;
    }

    vector<int> vec;
    vec.clear();
    ascent(i, 0, p.size()) {
      ascent(j, i, p.size()) {
	  vec.pb(p[i] + p[j]);
	  //	  cout << p[i] + p[j] << endl;
      }
    }

    sort(vec.begin(), vec.end());
    cout << vec[P-1] << endl;
  }

  return 0;
}

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

using namespace std;

typedef pair<int, int> P;

string str;

P expr(int);
P term(int);
P factor(int);
P number(int);

P expr(int idx)
{
  P res = term(idx);
  idx = res.first;
  int ans = res.second;
  
  while (idx < str.size() && (str[idx] == '+' || str[idx] == '-')) {
    res = term(idx + 1);
    bool plus = (str[idx] == '+');
    idx = res.first;
    
    if (plus) {
      ans += res.second;
    } else {
      ans -= res.second;
    }
  }
  return make_pair(idx, ans);
}

P term(int idx)
{
  P res = factor(idx);
  idx = res.first;
  int ans = res.second;
  
  while (idx < str.size() && (str[idx] == '*' || str[idx] == '/')) {
    res = factor(idx + 1);
    bool mult = (str[idx] == '*');
    idx = res.first;
    
    if (mult) {
      ans *= res.second;
    } else {
      ans /= res.second;
    }
  }
  return make_pair(idx, ans);
}

P factor(int idx)
{
  if (str[idx] == '(') {
    P res = expr(idx + 1);
    res.first++;
    return res;
  } else if (isdigit(str[idx])) {
    P res = number(idx);
    return res;
  }
}

P number(int idx)
{
  int N = 0;
  while (idx < str.size() && isdigit(str[idx])) {
    N *= 10;
    N += str[idx++] - '0';
  }
  return make_pair(idx, N);
}

void solve()
{
  int ans = expr(0).second;
  cout << ans << endl;
}

int main()
{
  int N;
  scanf("%d ", &N);
  
  for (int i = 0; i < N; i++) {
    getline(cin, str);
    str.erase(str.begin() + str.size() - 1);
    //cout << str << endl;
    solve();
  }
}