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 <algorithm>
#include <stack>
#include <vector>

using namespace std;

vector<string> toReversePorland(string str){

  vector<string> hand;
  vector<string> side;
  
  for(int i = 0; i < str.size(); i++){
    if(str[i] == ' ')
      continue;
    else if(str[i] == '=')
      break;
    if(str[i] >= '0' && str[i] <= '9'){
      string num;
      while(i < str.size()){
	if(str[i] < '0' || str[i] > '9'){
	  break;
	}
	num += str[i];
	i++;
      }
      hand.push_back(num);
      i--;
    }
    else if(str[i] == '('){
      string tmp;
      tmp += str[i];
      side.push_back(tmp);
    }
    else if(str[i] == ')'){
      // ツ右ツ環古環づ慊づ可可算ツ子ツづーツ暗ェツづつつクツづつ偲ィツ個ウツづ可姪淞つキ
      for(int j = side.size()-1 ; ;j--){
	if(side[j] == "("){
	  if(j != 0){
	    vector<string> tmp;
	    for(int k = 0; k < j; k++){
	      tmp.push_back(side[k]);
	    }
	    side = tmp;
	  }
	  else
	    side.clear();
	  break;
	}
	else{
	  string tmp = side[j];
	  hand.push_back(tmp);
	}
      }
    }
    else{
      if(side.size() == 0){
	string tmp;
	tmp += str[i];
	side.push_back(tmp);
      }
      else if(str[i] == '+' || str[i] == '-'){
	if(side[side.size()-1] == "*" || side[side.size()-1] == "/"){
	  hand.push_back(side[side.size()-1]);
	  string tmp;
	  tmp += str[i];
	  side[side.size()-1] = tmp;
	}
	else{
	  string tmp;
	  tmp += str[i];
	  side.push_back(tmp);
	}
      }
      else{
	if(side[side.size()-1] == "*" || side[side.size()-1] == "/"){
	  hand.push_back(side[side.size()-1]);
	  string tmp;
	  tmp += str[i];
	  side[side.size()-1] = string(tmp);
	}
	else{
	  string tmp;
	  tmp += str[i];
	  side.push_back(tmp);
	}
      }
    }
  }

  for(int i = side.size()-1; i >= 0; i--){
    hand.push_back(string(side[i]));
  }
  
  return hand;
}


int calc(vector<string> str){
  stack<int> st;
  for(int i = 0; i < str.size(); i++){
    if(str[i] == "+" || str[i] == "-" || str[i] == "*" || str[i] == "/"){
      int val[2];
      val[0] = st.top();
      st.pop();
      val[1] = st.top();
      st.pop();
      if(str[i] == "+"){
	st.push(val[0] + val[1]);
      }
      if(str[i] == "-"){
	st.push(val[1] - val[0]);
      }
      if(str[i] == "*"){
	st.push(val[0] * val[1]);
      }
      if(str[i] == "/"){
	st.push(val[1] / val[0]);
      }
    }
    else{
      st.push(atoi(str[i].c_str()));
    }
  }
  return st.top();
}

int main(){

  int n;
  string s;
  getline(cin,s);
  n = atoi(s.c_str());

  vector<string> input;
  string str;
  for(int i = 0; i < n; i++){
    getline(cin,str);
    input.push_back(str);
  }

  for(int i = 0; i < n; i++){
    str = input[i];
    // vector<string> vec = toReversePorland(str);
    // for(int i = 0; i < vec.size(); i++)
    //   cout << vec[i] << endl;
    cout << calc(toReversePorland(str)) << endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
string s;
int a;
int func();//+-
int num();
int func2();//*/
int func3();//()
int num(){
	int out=0;
	while(isdigit(s[a])){
		out*=10;out+=s[a]-'0';
		a++;
	}
	return out;
}
int func3(){
	int out;
	if(s[a]=='('){
		a++;
		out=func();
		a++;
	}else out=num();
	return out;
}
int func2(){
	int out=func3();
	while(1){
		if(s[a]=='*'){
			a++;
			out*=func3();
		}else if(s[a]=='/'){
			a++;
			out/=func3();
		}else break;
	}
	return out;
}	
int func(){
	int out=func2();
	while(1){
		if(s[a]=='+'){
			a++;out+=func2();
		}else if(s[a]=='-'){
			a++;out-=func2();
		}else break;
	}
	return out;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		a=0;
		cin>>s;
		//s="0+"+s;
		cout<<func()<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

string S;
size_t cur;
int parse();

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 term1(){
    int a=factor();
    while(cur<S.size()&&S[cur]=='^'){
	cur++;
	int b=factor();
	a=pow(a,b);
    }
    return a;
}

int term2(){
    int a=term1();
    while(cur<S.size()&&(S[cur]=='*'||S[cur]=='/')){
		char op=S[cur++];
		int b=term1();
		if(op=='*')a*=b; else a/=b;
    }
    return a;
}

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

int main() {
    while(cin>>S){
	cur=0;
	cout<<expression()<<endl;
    }
}

C++: 
#include<iostream>
#include<string>
#include<cassert>
#include<cctype>
#include<stdio.h>
using namespace std;

string S="4*(8+4+3)";
size_t cur=0;

int expression(); //????????£?¨?

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

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

//()???????¨????
int factor(){
	if(S[cur] !='(' ) return number();
	else{
		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 if(op=='/') a /=b;
	}
	return a;
}

//+,-????¨????
int expression(){
	int sum=term();
	while(S[cur]=='+' || S[cur]=='-'){
		char op=S[cur++];
		int b=term();
		if(op=='+') sum+=b;
		else if(op=='-') sum -=b;
	}
	return sum;
}

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