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 <map>
#include <algorithm>
#include <cctype>
using namespace std;

typedef string::const_iterator State;
int n;
string str;

int factor(State &begin);
int number(State &begin);
int term(State &begin);
int expressin(State &begin);

int factor(State &begin)
{
	int ret;
	if (*begin == '(')
	{
		begin++;
		ret = expressin(begin);
		begin++;
	}
	else
	{
		ret = number(begin);
	}
	return ret;
}

int number(State &begin)
{
	int ret = 0;
	while (isdigit(*begin))
	{
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}

int term(State &begin)
{
	int ret = factor(begin);
	while (true)
	{
		if (*begin == '*')
		{
			begin++;
			ret *= factor(begin);
		}
		else if (*begin == '/')
		{
			begin++;
			ret /= factor(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}

int expressin(State &begin)
{
	int ret = term(begin);
	while (true)
	{
		if (*begin == '+')
		{
			begin++;
			ret += term(begin);
		}
		else if (*begin == '-')
		{
			begin++;
			ret -= term(begin);
		}
		else
		{
			break;
		}
	}

	return ret;
}


int main()
{
	cin >> n;
	while (n--)
	{
		cin >> str;
		cout << expressin(str.begin()) << endl;
	}

	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)


string foo2(string s){
	// cout<<s<<endl;
	bool f=true;
	rep(i,s.size()){
		if(i==0){
			if(s[0]=='-');
			else f=false;
		}
		else{
			if(s[i]>='0'&&s[i]<='9'){

			}
			else{
				f=false;
			}
		}
	}
	if(f) return s;
	// bool f=false;
	rep(i,s.size()){
		if(s[i]=='*'||s[i]=='/'){
			int xl=i,xr=i;
			f=true;
			while(1){
				if(xl==0) break;
				else if(s[xl-1]>='0'&&s[xl-1]<='9'){
					xl--;
				}
				else{
					
					break;
				}
			}
			while(1){
				if(xr==s.size()-1) break;
				else if(s[xr+1]>='0'&&s[xr+1]<='9'){
					xr++;
				}
				else{
					
					break;
				}
			}
			stringstream ss1,ss2;
			// cout<<s.substr(xl,xr-xl+1)<<endl;
			ss1<<s.substr(xl,xr-xl+1);
			int a,b;
			char t;
			ss1>>a;
			// cout<<"a "<<a<<endl;
			ss1>>t;
			ss1>>b;
			ss2<<s.substr(0,xl);
			int tt;
			if(t=='*'){
				tt=a*b;
			}
			else{
				tt=a/b;
			}
			ss2<<tt;
			ss2<<s.substr(xr+1);
			ss2>>s;
			// cout<<"foo2 "<<s<<" "<<endl;
			return foo2(s);
		}
	}
	rep(i,s.size()){
		if(s[i]=='+'||s[i]=='-'){
			int xl=i,xr=i;
			f=true;
			while(1){
				if(xl==0) break;
				else if(s[xl-1]>='0'&&s[xl-1]<='9'){
					xl--;
				}
				else{
					break;
				}
			}
			while(1){
				if(xr==s.size()-1) break;
				else if(s[xr+1]>='0'&&s[xr+1]<='9'){
					xr++;
				}
				else{
					break;
				}
			}
			stringstream ss1,ss2;
			ss1<<s.substr(xl,xr-xl+1);
			int a,b;
			char t;
			ss1>>a;
			ss1>>t;
			ss1>>b;
			ss2<<s.substr(0,xl);
			int tt;
			if(t=='+'){
				tt=a+b;
			}
			else{
				tt=a-b;
				// cout<<tt<<endl;
			}
			ss2<<tt;
			ss2<<s.substr(xr+1);
			ss2>>s;
			return foo2(s);
		}
	}
	return s;
}

string foo1(string s){
	// cout<<s<<endl;
	int xl=-1,xr=-1;
	rep(i,s.size()){
		if(s[i]=='('){
			xl=i;
		}
		else if(s[i]==')'){
			xr=i;
			break;
		}
	}
	if(xr!=-1){

		return foo2(foo1(s.substr(0,xl)+s.substr(xl+1,xr-xl-1)+s.substr(xr+1)));
	}
	return foo2(s);
}

string solve(string s){
	return foo1(s);
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		s=s.substr(0,s.size()-1);
		s=solve(s);
		cout<<s<<endl;
	}
}

C++: #include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int i;
string str;
int Expression();
int Term();
int Factor();
int No(int);
int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> str;
    i = 0;
    cout << Expression() << endl;
  }
}
int Expression(){
  int res = Term();
  while(1){
    switch(str[i]){
    case '+':
      i++;
      res += Term();
      break;
    case '-':
      i++;
      res -= Term();
      break;
    default:
      return res;
    }
  }
}
int Term(){
  int res = Factor();
  while(true){
    switch(str[i]){
    case '(':
      i++;
      res += Factor();
      break;
    case '*':
      i++;
      res *= Factor();
      break;
    case '/':
      i++;
      res /= Factor();
      break;
    default:
      return res;
    }
  }
}
int Factor(){
  int res = 0;
  switch(str[i]){
  case '(':
    i++;
    res = Expression();
    i++;
    return res;
  default:
    return No(i);
  }
}
int No(int old){
  while(isdigit(str[i])) i++;
  return atoi((str.substr(old,i)).c_str());
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

/*
equation := equation + factor | factor
factor   := factor   * term   | term
term     := (equation) | Number 

↓

equation := factor (+ factor)*
factor   := term (* term)*
term     := (equation) | Number 
 */
int equation();
int term();
int factor();
int id;
string s;

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		cin >> s;
		id = 0;
		cout << equation() << endl;
	}
}

int equation()
{
	int left = term();
	while(s[id] == '+' || s[id] == '-')
	{
		if(s[id] == '+')
		{
			id++;
			int right = term();
			left += right;
		}
		if(s[id] == '-')
		{
			id++;
			int right = term();
			left -= right;
		}
	}
	return left;
}
int term()
{
	int left = factor();
	while(s[id] == '*' || s[id] == '/')
	{
		if(s[id] == '*')
		{
			id++;
			int right = factor();
			left *= right;
		}
		if(s[id] == '/')
		{
			id++;
			int right = factor();
			left /= right;
		}
	}
	return left;
}
int factor()
{
	char c = s[id];
	if(c == '(')
	{
		id++;
		int res = equation();
		id++;
		return res;
	}
	else
	{
		int res = 0;
		while(isdigit(s[id]))
		{
			res = res*10 + (s[id++]-'0');
		}
		return res;
	}
}

C++: gets;$<.each_line.map{|s|p eval(s[0..-3])}