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>
using namespace std;
int exp();
int term();
int factor();
int number();
int digit();
int p=0;
string str;
int main(){
  int n,re;
  cin >> n;
  while(n){
    p=0;
    cin >> str;
    re=exp();
    cout << re << endl;
    n--;
  }
  return 0;
}
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 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 factor(){
  int val;
  if(str[p]=='('){
    p++;
    val=exp();
    p++;
  }else{
    val=digit();
  }
  return val;
}
int number(){
  int val=digit();
  return val;
}
int digit(){
  int ret,cnt=0;
  while(1){
    if(cnt==0&&'0'<=str[p]&&str[p]<='9'){
      ret=str[p]-'0';
      p++;
      cnt=1;
    }
    else if(cnt==1&&'0'<=str[p]&&str[p]<='9'){
      ret=ret*10+(str[p]-'0');
      p++;
    }
    else{
      break;
    }
  }
  /*  if('0' <= str[p] && str[p] <= '9') {
    if(cnt==0){
      ret=str[p]-'0';
      cnt=1;
    }
    p++;
    if('0' <= str[p] && str[p] <= '9') {
      ret=ret*10+(str[p]-'0');
      digit();
    }
    return ret;
    }*/
  return ret;
}

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

using namespace std;

string S;
size_t cur = 0;

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

char peek() {
  assert(cur < S.size());
  return S[cur];
}

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

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

int expression();

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

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



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

int parse() {
  return expression();
}

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> S;
    int a = parse();
    cout << a << endl;
    cur = 0;
  }
  return 0;
}

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

bool digit(char c){
  return (c-'0'>=0 && c-'0'<=9);
}

int stoi(string s){
  int res,tmp;
  res = 0;
  tmp = 1;
  for(int i=(int)s.size()-1;i>=0;i--){
    res += (s[i]-'0') * tmp;
    tmp *= 10;
  }
  return res;
}

int cal(string s){
  vector<int> v,op;
  int pos = 0;
  while(pos<(int)s.size()){
    if(s[pos] == '('){
      int c = 1;
      string tmp;
      while(1){
	pos++;
	if(s[pos] == '(')c++;
	if(s[pos] == ')')c--;
      if(!c)break;
      tmp.push_back(s[pos]);
      }
      v.push_back(cal(tmp));
      pos++;
    }else if(digit(s[pos])){
      string tmp;
      while(digit(s[pos])){
	tmp.push_back(s[pos]);
	pos++;
      }
      v.push_back(stoi(tmp));
    }else{
      op.push_back(s[pos]);
      pos++;
    }
  }
    
  for(int i=0;i<(int)op.size();i++){
    if(op[i] == '*'){
      int tmp = v[i]*v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
    if(op[i] == '/'){
      int tmp = v[i]/v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
  }
  for(int i=0;i<(int)op.size();i++){
    if(op[i] == '+'){
      int tmp = v[i]+v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
    if(op[i] == '-'){
      int tmp = v[i]-v[i+1];
      v.insert(v.begin()+i,tmp);
      v.erase(v.begin()+i+1);
      v.erase(v.begin()+i+1);
      op.erase(op.begin()+i);
      i = - 1;
    }
  }
  return v[0]; 
}

int main(){
  string s;
  int n;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    s.erase(s.end()-1);
    cout << cal(s) << endl;
  }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;


string st;
int a;

int plmi();

int num() {
	int n = 0;
	while (1) {
		if (isdigit(st[a])) {
			n *= 10;
			n += st[a] - '0';
			a++;
		}
		else {
			return n;
		}
	}
}

int siki() {
	int n;
	if (st[a] == '(') {
		a++;
		n=plmi();
		a++;
	}
	else {
		n = num();
	}
	return n;
}

int evdi() {
	int n = siki();
	while (1) {
		if (st[a] == '*') {
			a++;
			n *= siki();
		}
		else if (st[a] == '/') {
			a++;
			n /= siki();
		}
		else {
			break;
		}
	}
	return n;
}

int plmi() {
	int n=evdi();
	while (1) {
		if (st[a] == '+') {
			a++;
			n += evdi();
		}
		else if (st[a] == '-') {
			a++;
			n -= evdi();
		}
		else {
			break;
		}
	}
	
	return n;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> st;
		a = 0;
		int ans=plmi();
		cout << ans << endl;
	}
	return 0;
}

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

string s;

int si(int&);
int fi(int&);
int so(int&);

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		int pos = 0;
		cout << so(pos) << endl;
	}

	return 0;
}
int so(int& pos){
	int ans = fi(pos);
	while (s[pos] != '=' && s[pos] != ')'){
		if (s[pos] == '+'){
			ans += fi(++pos);
		}
		else if (s[pos] == '-'){
			ans -= fi(++pos);
		}
	}
	pos++;
	return ans;
}
int fi(int& pos){
	int ans = si(pos);
	while (1){
		if (s[pos] == '*'){
			ans *= si(++pos);
		}
		else if (s[pos] == '/'){
			ans /= si(++pos);
		}
		else {
			return ans;
		}
	}
}

int si(int& pos){
	if (s[pos] != '('){
		int ans = 0;
		while ('0' <= s[pos] && s[pos] <= '9'){
			ans *= 10;
			ans += s[pos] - 48;
			pos++;
		}
		return ans;
	}
	else{
		return so(++pos);
	}
}

C++: #include<iostream>
#include<cassert>
#include<algorithm>

using namespace std;

char *pt;
int parseAtom();
int parseExpr();
int parseTerm();


int parseAtom(){
	if('0' <= *pt && *pt <= '9'){
		int x = *pt - '0';
		pt++;
		while('0' <= *pt && *pt <= '9'){
			x = x * 10 + *pt - '0';
			pt++;
		}
		return x;
	}
	if('(' == *pt){
		pt++;
		int x = parseExpr();
		assert(*pt == ')');
		pt++;
		return x;
	}
	assert(false);
	return -1;
}
int parseExpr(){
	int x = parseTerm();
	while(*pt == '+' || *pt == '-'){
		if(*pt == '+'){
			pt++;
			x += parseTerm();
		}else {
			pt++;
			x -= parseTerm();
		}
	}
	return x;
}
int parseTerm(){
	int x = parseAtom();
	while(*pt == '*' || *pt == '/'){
		if(*pt == '*'){
			pt++;
			x *= parseAtom();
		} else{
			x /= parseAtom();
		}
	}
	return x;
}
int main(void){
	int n ;
	cin>>n;
	for(int i = 0 ; i < n ;  i ++){
		static char expr[200];
		cin>>expr;
		pt=expr;
		int x = parseExpr();
		assert(*pt == '=');
		cout<<x<<endl;
	}
	return 0;
}