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>
#include<sstream>
using namespace std;

typedef long long ll;

ll stol(string s){
  stringstream ss(s);
  ll n;
  ss >> n;
  return n;
}

ll parse(int l, int r){
  int n = 0,i;
  for(i=r-1;i>=l;i--){
    if(s[i] == ‘)‘)n++;  if(s[i] == ‘(’)n--;
    if(!n){
      if(s[i] == ‘+’)return parse(l,i)+parse(i+1,r);
      if(s[i] == ‘-’)return parse(l,i)-parse(i+1,r);
    }
  }
  for(i=r-1;i>=l;i--){
    if(s[i] == ‘)‘)n++;  if(s[i] == ‘(’)n--;
    if(!n){
      if(s[i] == ‘*’)return parse(l,i)*parse(i+1,r);
      if(s[i] == ‘/’)return parse(l,i)/parse(i+1,r);
    }
  }

  if(s[l] == ‘(‘ && s[r-1] == ‘)’)return parse(l+1,r-1);
  return stol(s.substr(l,r-l));
}

int main(){
  int n;
  string s;
  cin >> n;
  while(n--){
    cin >> s;
    cout << parse(0,(int)s.size()-1) << endl;
  }
}

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

  //  cout <<"one"<< num << endl;
  if(num != 0) return num;

  else if (str[p] == '('){
    p++;
    num = exp();
  }
  if(str[p] == ')'){
    // cout <<"two"<< num << endl;
    p++;
    return num;
  } 
  return 0;
}

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