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 <cstdio>

using namespace std;

int r;
int i;
int sd(char *s, int m){
    int n = 0, d = 0;
    for(;s[i] != '\0';){
        switch(s[i]){
        case '=':
            return n;
        case '+':
            if(m == 1)
                return n;
            i++;
            return n + sd(s, 2);
        case '-':
            if(m == 1)
                return n;
            i++;
            return n - sd(s, 2);
        case '*':
            i++;
            return n * sd(s, 1);
        case '/':
            i++;
            return n / sd(s, 1);
        case '(':
            i++;
            return sd(s, 0);
        case ')':
            i++;
            return n;
        default:
            n = n * 10 + s[i] - '0';
            i++;
            break;
        }
    }
}

int main(void)
{
    int N;

    char str[1024];

    cin >> N;

    for(int k = 0; k < N; k++){
        r = 0;
        i = 0;
        cin >> str;
        printf("%d", sd(str, 0));
    }
}

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; 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; psh[++pp] = stk[i], 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; 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; calc(p[i++]));
}

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

using namespace std;

string S;
size_t cur=0;

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

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

int expression();

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

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

// accepted!
#if 0
???????????????pdf?????????????????????????????§?????¨?????§45?????????
?????°??????????????¨??§?????????????????????????°?????????????????????¨???????????§?????????
#endif

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


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


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

	while (true){
		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 (true){
		if (*begin == '*'){
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/'){
			begin++;
			ret /= factor(begin);
		}
		else {
			break;
		}
	}

	return ret;
}


int factor(State& begin){
	int ret;
	if (*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else {
		ret = number(begin);
	}
	return ret;
}


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

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

	return ret;
}


int main(){
	int n;
	string expr;

	cin >> n;
	cin.ignore();

	for (int i = 0; i < n; i++){
		getline(cin, expr);

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

	return 0;
}

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

int expression(State &);
int term(State &);
int factor(State &);
int number(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 factor(State &begin){
  if(*begin=='('){
    begin++;
    int ret=expression(begin);
    begin++;
    return ret;
  }
  if(*begin=='-'){
    begin++;
    return -factor(begin);
  }
  return number(begin);
}

int number(State &begin){
  int ret=0;
  
  while(isdigit(*begin)){
    ret*=10;
    ret+=*begin-'0';
    begin++;
  }
  return ret;
}