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

long calc2(char *eq){
	long 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(long 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(long j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

long calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	long k,ret;
	strcpy(cp, eq);
	if((p=strchr(cp, '('))!=NULL){
		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%ld%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

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

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

using namespace std;

string str;
int cur = 0;

int expression();
int term();
int factor();

int digit() {
    int a = str[cur] - '0';
    cur++;
    return a;
}

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

int expression() {
    int a = term();
    while (cur < str.size() && (str[cur] == '+' || str[cur] == '-')) {
        if (str[cur] == '+') {
            cur++;
            int b = term();
            a += b;
        } else if (str[cur] == '-') {
            cur++;
            int b = term();
            a -= b;
        }
    }
    return a;
}

int term() {
    int a = ((str[cur] == '(') ? factor() : number());
    while (cur < str.size() && (str[cur] == '*' || str[cur] == '/')) {
        if (str[cur] == '*') {
            cur++;
            int b = ((str[cur] == '(') ? factor() : term());
            a *= b;
        } else if (str[cur] == '/') {
            cur++;
            int b = ((str[cur] == '(') ? factor() : term());
            a /= b;
        }
    }
    return a;
}

int factor() {
    cur++;
    int a = expression();
    cur++;
    return a;
}

int main() {
    int N = 0;
    cin>>N;
    for (int n = 0; n < N; n++) {
        cin>>str;
        cur = 0;
        cout<<expression()<<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <stack>

using namespace std;

int calc(string s){
	// ©gªÊÉÍÜêÄ¢éêÆAÅ éÆ«Ì
	if(s[0]>='0'&&s[0]<='9'){
		bool f=false;
		for(int i = 0; i < s.size(); i++){
			if(!(s[i]>='0'&&s[i]<='9')){
				f=true;
				break;
			}
		}
		if(!f){
			return atoi(s.c_str());
		}
	}
	else if(s[0]=='('){
		stack<char> sc;
		sc.push('(');
		for(int i = 1; i < s.size(); i++){
			if(s[i]==')')
				sc.pop();
			else if(s[i]=='('){
				sc.push('(');
			}
			if(sc.size()==0){
				if(i==s.size()-1){
					return calc(s.substr(1,s.size()-2));
				}
				else{
					break;
				}
			}
		}
	}
	stack<char> sc;
	// \¶ðÍÆÓ¡ðÍ
	for(int i = 0; i < s.size(); i++){
		// ÊÌÌZqÍ³·é
		if(s[i]=='(')
			sc.push('(');
		else if(s[i]==')'){
			sc.pop();
		}
		else if(s[i]=='+'&&sc.size()==0){
			return calc(s.substr(0,i)) + calc(s.substr(i+1,s.size()-i-1));
		}
		else if(s[i]=='-'&&sc.size()==0){
			return calc(s.substr(0,i)) - calc(s.substr(i+1,s.size()-i-1));
		}
		else if(s[i]=='*'&&sc.size()==0){
			return calc(s.substr(0,i)) * calc(s.substr(i+1,s.size()-i-1));
		}
		else if(s[i]=='/'&&sc.size()==0){
			return calc(s.substr(0,i)) / calc(s.substr(i+1,s.size()-i-1));
		}
	}
}

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		string str;
		cin>>str;
		cout<<calc(str.substr(0,str.size()-1))<<endl;
	}

	return 0;
}

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

class Parser {
public:
  std::string str;
  int idx;
  Parser (std::string str):str(str),idx(0)
  {
  }
  int evalas();
  int evalmd();
  int evalexpr();
  int evalnum();
};

int Parser::evalas() {
  int left = evalmd(), right;
  while(true) {
    switch(str[idx]) {
    case '+':
      idx++;
      right = evalmd();
      left = left+right;
      break;
    case '-':
      idx++;
      right = evalmd();
      left = left-right;
      break;
    default:
      goto hoge;
    }
  }
 hoge:
  return left;
}

int Parser::evalmd() {
  int left = evalexpr(),right;
  while(true) {
    switch(str[idx]) {
    case '*':
      idx++;
      right = evalexpr();
      left = left*right;
      break;
    case '/':
      idx++;
      right = evalexpr();
      left = left/right;
      break;
    default:
      goto hoge;
    }
  }
 hoge:
  return left;
}

int Parser::evalexpr() {
  int n;
  if (str[idx] == '(') {
    idx++;
    n = evalas();
    idx++;
  } else {
    n = evalnum();
  }
  return n;
}

int Parser::evalnum() {
  int ans=0;
  char ch;
  while (isdigit(ch=str[idx])) {
    idx++;
    ans = ans*10+(int)ch-(int)'0';
  }
  return ans;
}

int main() {
  int time;
  scanf("%d\n",&time);
  while(time--) {
    char str[100];
    fgets(str,100,stdin);
    printf("%d\n",Parser(std::string(str)).evalas());
  }
}

C++: #include<iostream>
#include<cctype>
#include<cassert>
using namespace std;

string s;
int cur;

int factor();

char readchar(){
  assert(cur <s.size());
  char ret =s[cur];
  cur += 1;
  return ret;
}

char peak(){
  assert(cur<s.size());
  return s[cur];
}

int digit(){
  assert(isdigit(peak()));
  int n = readchar() - '0';
  return n;
}

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

int term(){
  int a = factor();
  while((cur <s.size()) && (peak()=='*' || peak() == '/')){
    char op = readchar();
    int b = factor();
    if(op=='*') a*=b; else a/=b;
  }

  return a;
}
    
int expression(){
  int a=term();
  while((cur<s.size())&& (peak()=='+' || peak() == '-')){
    char op = readchar();
    int b= term();
    if(op == '+') a+=b;else a-=b;
  }
  return a;
}

int factor(){
  if(peak() != '(') return number();
  cur += 1;
  int n = expression();
  assert(peak() == ')');
  cur+=1;
  return n;
}


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