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 <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
LL plusub(void);
LL muldiv(void);
LL parent(void);
LL number(void);

int ind;
string str;

LL plusub(void){
  LL a=muldiv();
  if(str[ind]=='+'){
    ++ind;
    return a+plusub();
  }else if(str[ind]=='-'){
    ++ind;
    return a-plusub();
  }else return a;
}

LL muldiv(void){
  LL a=parent();
  if(str[ind]=='*'){
    ++ind;
    return a*muldiv();
  }else if(str[ind]=='/'){
    ++ind;
    return a/muldiv();
  }else return a;
}

LL parent(void){
  if(str[ind]=='('){
    ++ind;
    LL a=plusub();
    ++ind;
    return a;
  }else return number();
}

LL number(void){
  if('0'<=str[ind] && str[ind]<='9'){
    LL a=str[ind]-'0';
    ++ind;
    LL b=number();
    if(0<=b&&b<=9) return a*10+b;
    else return a;
  }else return -1;
}

int main(void)
{
  int n;
  cin >> n;
  REP(i,n){
    ind=0;
    cin >> str;
    cout << plusub() << endl;
  }
  return 0;
}

C++: //Smart Calculator
#include <iostream>
#include <cstdio>
#include <cassert>
#define rep(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
using namespace std;
string S;
size_t cur = 0;
bool isdigit(char);
int digit();
int number();
int term();
int expression();
int factor();
int parse(){
    return expression();
}

int main(){
    int n;
    cin >> n;
    rep(i,n){
        cur = 0;
        cin >> S;
        S.resize(S.size()-1);
        cout << parse() << endl;
    }
}

bool isdigit(char c){
    return c >= '0' && c <= '9';
}
int digit(){
    assert(isdigit(S[cur]));
    int n = S[cur] - '0';
    cur = cur + 1;
    return n;
}
int number(){
    int n = digit();
    while(cur<S.size()&&isdigit(S[cur])){
        n = n*10+digit();
    }
    return n;
}

int expression(){
    int mult = 1;
    if(S[cur]=='-'){
        mult = -1;
        cur++;
    }
    int sum = term()*mult;
    while(cur < S.size()&&(S[cur]=='+'||S[cur]=='-')){
        char op = S[cur];
        cur++;
        if(op == '+'){
            sum += term();
        }else{
            sum -= term();
        }
    }
    return sum;
}
int term(){
    int ret = factor();
    while(cur < S.size() &&( S[cur]=='*'||S[cur]=='/')){
        char op = S[cur];
        cur++;
        if(op == '*'){
            ret *= factor();
        }else{
            ret /= factor();
        }
    }
    return ret;
}
int factor(){
    if(S[cur]!='(')
        return number();
    cur += 1;
    int n = expression();
    assert(S[cur]==')');
    cur++;
    return n;
}

C++: #include <iostream>
using namespace std;
char str[120];

int calc2(char *eq){
	int c=0,num[100]={0}, sign[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	printf("return %s=%d\n", eq, num[0]);
	return num[0];
}

int calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	int k,ret;
	strcpy(cp, eq);
	if(p=strchr(cp, '(')){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%d%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

int main(){
	int i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
}

C++: #include <string>
#include <cctype>
#include <iostream>
typedef std::string::const_iterator State;
class ParseError {};

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++;
	}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;
	std::cin >> N;
	std::cin.ignore();
	for(int i = 0; i < N; ++i){
		std::string s;
		std::getline(std::cin, s);
		State begin = s.begin();
		int ans = expression(begin);
		std::cout << ans << std::endl;
	}
	return 0;
}

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

using namespace std;

string S;
size_t cur;

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

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

int expression();

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

int term(){
  int t=factor();
  for(;cur<S.size()&&(S[cur]=='*'||S[cur]=='/');){
    if(S[cur++]=='*')t*=factor();
	else t/=factor();
  }
  return t;
}

int expression(){
  int t=term();
  for(;cur<S.size()&&(S[cur]=='+'||S[cur]=='-');){
    if(S[cur++]=='+')t+=term();
	else t-=term();
  }
  return t;
}

int main(){
  int n;
  cin>>n;
  for(;n--;){
    cur=0;
    cin>>S;
	cout<<expression()<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
string str;
int p;

int exp();
int factor();
int term();

int factor() {
  int num=0;
  while('0' <= str[p] && str[p] <= '9') {
    num*=10;
    num += str[p] - '0';
    p++;
  }

  if (str[p] == '('){
    p++;
    num = exp();
    p++;
  }
  return num;
}

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