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>

using namespace std;

int cal(string&);
int expression(string&, int&);
int kou(string&, int&);
int num(string&, int&);

int cal(string& s) {
	int pos = 0;
	return expression(s, pos);
}
int expression(string& s, int& pos) {
	int left = kou(s, pos);
	while (1) {
		char op = s[pos++];
		if (op == '+') {
			int right = kou(s, pos);
			left += right;
		}
		else if (op == '-') {
			int right = kou(s, pos);
			left -= right;
		}
		else if (op == '=') {
			return left;
		}
		else if (op == ')') {
			return left;
		}
	}
}
int kou(string& s, int& pos) {
	int left = num(s, pos);
	while (1) {
		char op = s[pos++];
		if (op == '*') {
			left *= num(s, pos);
		}
		else if (op == '/') {
			left /= num(s, pos);
		}
		else {
			--pos;
			return left;
		}
	}
}
int num(string& s, int& pos) {
	int ret = 0;
	if (s[pos] == '(') {
		++pos;
		return expression(s, pos);
	}
	else {
		while ('0' <= s[pos] && s[pos] <= '9') {
			ret *= 10;
			ret += s[pos] - '0';
			++pos;
		}
	}
	return ret;
}


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

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

string S;
size_t cur = 0;
int parse();
int number();
int expression();
int factor();
char readchar();
char peek();

//------ number ------

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

int number()
{
    int n = digit();
    while (peek() != '=' && isdigit(peek()))
    {
        n = n * 10 + digit();
    }
    return n;
}

//------ expression ------

int term()
{
    int a = factor();
    while (peek() != '=' && peek() != ')' && (peek() == '*' || peek() == '/'))
    {
        char op = readchar();
        int b = factor();

        if (op == '*')
            a *= b;
        else if (op == '/')
            a /= b;
    }
    return a;
}

int expression()
{
    int a = term();
    while (peek() != '=' && peek() != ')' && (peek() == '+' || peek() == '-'))
    {
        char op = readchar();
        int b = term();

        if (op == '+')
            a += b;
        else if (op == '-')
            a -= b;
    }
    return a;
}

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

//------ parse ------

int parse()
{
    cur = 0;
    return expression();
}

//------ READ ------

char readchar()
{
    char ret = S[cur++];
    return ret;
}
char peek()
{
    return S[cur];
}

//------------------

int main()
{
    int N;
    cin >> N;
    for (size_t i = 0; i < (size_t)N; i++)
    {
        cin >> S;
        int ans = parse();
        cout << ans << endl;
    }
}

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

using namespace std;

string s;

bool isDigit(char c)
{
	return (c >= '0' && c <= '9');
}
int parseNumber(string &s, int &pos)
{
	int ret = 0;
	while(1){
		if(isDigit(s[pos])) ret *= 10, ret += s[pos]-'0';
		else break;
		pos++;
	}
	return ret;
}
int parseExp(string &s, int &pos);
int parseFactor(string &s, int &pos)
{
	if(s[pos] == '('){
		pos++;
		int ret = parseExp(s, pos);
		pos++;
		return ret;
	}
	else if(isDigit(s[pos])) return parseNumber(s, pos); 
}
int parseTerm(string &s, int &pos)
{
	int ret = 1;
	ret *= parseFactor(s, pos);
	while(1){
		if(s[pos] == '*'){
			pos++;
			ret *= parseFactor(s, pos);
		}
		else if(s[pos] == '/'){
			pos++;
			ret /= parseFactor(s, pos);
		}
		else break;
	}
	return ret;
}
int parseExp(string &s, int &pos)
{
	int ret = 0;
	ret += parseTerm(s, pos);
	while(1){
		if(s[pos] == '+'){
			pos++;
			ret += parseTerm(s, pos);
		}
		else if(s[pos] == '-'){
			pos++;
			ret -= parseTerm(s, pos);
		}
		else break;
	}
	return ret;
}

int main(void)
{
	int T;
	cin >> T;
	for(int t = 0; t < T; t++){
		cin >> s;
		int pos = 0;
		cout << parseExp(s, pos) << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;



string tranceRPN(string in_formula, string out_formula, stack<char> st){
    
    if(in_formula.size() == 0){
        while(!st.empty()){
            out_formula+=st.top();
            st.pop();
        }
        //cout<<st.top()<<endl;;;
        return out_formula;//処理終了
    }
    
    char top = in_formula[0];
    in_formula.erase(0,1);
    //cout<<in_formula<<endl;
    
    if(top=='=')return tranceRPN(in_formula,out_formula,st);
    
    if(('0'<=top&&top<='9')||top==' ')out_formula+=top;
    else if(top==')'){
        while(1){
            if(st.top()=='('){
                st.pop();
                break;
            }
            out_formula+=st.top();
            st.pop();
        }
    }else if(top=='(')st.push(top);
    else if(st.empty())st.push(top);
    else if(((st.top()=='*'||st.top()=='/')&&(top=='+'||top=='-'))
            ||((st.top()=='*'||st.top()=='/')&&(top=='*'||top=='/'))
            ||((st.top()=='+'||st.top()=='-')&&(top=='+'||top=='-'))
            ){
        out_formula+=st.top();
        st.pop();
        in_formula=top+in_formula;
    }else{
        st.push(top);
    }
    return tranceRPN(in_formula,out_formula,st);
    
    
}

int RPN(string s){
    int x=0;
    stack<int> st;
    bool flag=false;
    while(1){
        if(s.size()==0){
            break;
        }else if('0'<=s[0]&&s[0]<='9'){
            x=x*10+s[0]-'0';
            flag=true;
            s.erase(0,1);
        }else if(s[0]==' '&&flag){
            flag=false;
            st.push(x);
            x=0;
            s.erase(0,1);
        }else if(s[0]=='+'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(y+z);
        }else if(s[0]=='-'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(z-y);
        }else if(s[0]=='*'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(y*z);
        }else if(s[0]=='/'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(z/y);
        }else{
            s.erase(0,1);
        }
    }
    return st.top();
}
/*
(1+4)*(3+7)/5
 
 
*/

int main(){
    
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string s,rs;
        stack<char> st;
        cin>>s;
        
        for(int i=0; i<s.length(); i++){
            if(s[i]=='+'||s[i]=='*'||s[i]=='-'||s[i]=='/'||s[i]==')'||s[i]=='('||s[i]=='=')s.insert(i++, " ");
        }
        s+=" ";
        //cout<<s<<endl;
        
        rs=tranceRPN(s,rs,st);
        //cout<<rs<<endl;
        
        cout<<RPN(rs)<<endl;
    }
    
    
    
}