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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int n,tmp,op1,work;
	char line[101],calc;
	stack<int> NUM,work_num;
	stack<char> OP,work_op;

	bool numFLG,negFLG;

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s",line);

		tmp = 0;
		numFLG = false;
		negFLG = false;

		for(int k = 0; line[k] != '\0'; k++){
			if(line[k] >= '0' && line[k] <= '9'){
				numFLG = true;
				tmp = 10*tmp + (line[k] - '0');
			}else{

				if(numFLG == true){
					if(negFLG){
						tmp = -1*tmp;
						negFLG = false;
					}

					if(OP.empty() == false && (OP.top() == '*' || OP.top() == '/')){
						calc = OP.top();
						OP.pop();
						op1 = NUM.top();
						NUM.pop();

						if(calc == '*'){
							NUM.push(tmp*op1);
						}else{
							NUM.push(op1/tmp);
						}
					}else{
						NUM.push(tmp);
					}

					numFLG = false;
					tmp = 0;
				}


				if(line[k] == '+' ||line[k] == '*' || line[k] == '/' || line[k] == '('){
					OP.push(line[k]);
				}else if(line[k] == '-'){
					if(k == 0){
						negFLG = true;
					}else if(k > 0 && line[k-1] == ('+' || '-' || '*' || '-' || '(')){
						negFLG = true;
					}else{
						OP.push('-');
					}

				}else if(line[k] == ')'){

					work = NUM.top();
					NUM.pop();
					work_num.push(work);

					while(true){
						calc = OP.top();
						OP.pop();
						if(calc == '(')break;

						work_op.push(calc);

						work = NUM.top();
						NUM.pop();
						work_num.push(work);
					}

					work = work_num.top();
					work_num.pop();

					while(!work_num.empty()){
						calc = work_op.top();
						work_op.pop();

						if(calc == '+'){
							work += work_num.top();
						}else if(calc == '-'){
							work -= work_num.top();
						}else if(calc == '*'){
							work *= work_num.top();
						}else{
							work /= work_num.top();
						}
						work_num.pop();
					}

					NUM.push(work);

				}else{

					work = NUM.top();
					NUM.pop();
					work_num.push(work);

					while(!NUM.empty()){
						calc = OP.top();
						OP.pop();

						work_op.push(calc);

						work = NUM.top();
						NUM.pop();
						work_num.push(work);
					}

					work = work_num.top();
					work_num.pop();

					while(!work_num.empty()){
						calc = work_op.top();
						work_op.pop();

						if(calc == '+'){
							work += work_num.top();
						}else if(calc == '-'){
							work -= work_num.top();
						}else if(calc == '*'){
							work *= work_num.top();
						}else{
							work /= work_num.top();
						}
						work_num.pop();
					}

					printf("%d\n",work);
				}
			}
		}

	}


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

  if ( str[p] == ')' ) 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;
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string toRPN(string s){
    stack<char> ope;
    string ret="";
    int len=s.size();
    
    for(int i=0;i<len;i++){
        if( isdigit(s[i]) ) ret+=s[i];
        
        else{
            if(s[i]=='('){
                ope.push(s[i]);
                
            }else if(s[i]==')'){
                while(ope.top()!='('){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.pop();
                
            }else if( s[i]=='*' || s[i]=='/' ){
                while( !ope.empty() && (ope.top()=='*' || ope.top()=='/') ){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.push(s[i]);
                
            }else if( s[i]=='+' || s[i]=='-' ){
                while( !ope.empty() && (ope.top()=='*' || ope.top()=='/' || ope.top()=='+' || ope.top()=='-') ){
                    ret+=ope.top();
                    ope.pop();
                }
                ope.push(s[i]);
                
            }else{
                return "invalid";
            }
        }
    }
    while(ope.size()){
        ret+=ope.top();
        ope.pop();
    }

    return ret;
}


string solveRPN(string s){
    stack<int> stk;

    
    for(int i=0;i<s.size();i++){
        if( isdigit(s[i]) )stk.push( s[i]-'0'  );
        else{
            int b=stk.top(); stk.pop();
            int a=stk.top(); stk.pop();
            
            
            if(s[i]=='+')stk.push(a+b);
            if(s[i]=='-')stk.push(a-b);
            if(s[i]=='*')stk.push(a*b);
            if(s[i]=='/')stk.push(a/b);
        }
    }
    
    stringstream ret;
    ret<<stk.top();
    
    return ret.str();
}


int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        
        s.erase(s.size()-1);
        
        s=toRPN(s);
//        s=solveRPN(s);
    
        cout<<s<<endl;
    }
    
    return 0;
}