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 <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define for(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define mp make_pair
#define x first
#define y second

using namespace std;

static const double eps = 1e-9;

typedef pair<int, int> p;
typedef long long ll;

template<class t>
inline t sq(t a){return a*a;}

int expr();
int term();
int num();

string s;
int ptr;
int expr(){
	int x = term();
	if(s[ptr] == '+'){
		ptr++;
		x += expr();
	}else if(s[ptr] == '-'){
		ptr++;
		x -= expr();
	}
	return x;
}

int term(){
	int x, y = 1;
	if(s[ptr] == '+') ptr++;
	if(s[ptr] == '-'){
		y = -1;
		ptr++;
	}
	if(s[ptr] == '('){
		ptr++;
		x = expr();
		ptr++;
	}else{
		x = num();
	}
	if(s[ptr] == '*'){
		ptr++;
		x *= term();
	}
	else if(s[ptr] == '/'){
		ptr++;
		x/= term();
	}
	return x*y;
}

int num(){
	int x = 0;
	while('0' <= s[ptr] && s[ptr] <= '9'){
		x *= 10;
		x += (s[ptr]-'0');
		ptr++;
	}
	return x;
}


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

	return 0;
}

C++: #include <cctype>
#include <string>
#include <iostream>
using namespace std;
typedef string::const_iterator State;

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

int expression(State&);

int factor(State& it) {
	if (*it == '(') {
		++it;
		int result = expression(it);
		++it;
		return result;
	}
	else return number(it);
}

int term(State& it) {
	int result = factor(it);
	for (;;) {
		if (*it == '*') {
			++it;
			result *= factor(it);
		}
		else if (*it == '/') {
			++it;
			result /= factor(it);
		}
		else break;
	}
	return result;
}

int expression(State& it) {
	int result = term(it);
	for (;;) {
		if (*it == '+') {
			++it;
			result += term(it);
		}
		else if (*it == '-') {
			++it;
			result -= term(it);
		}
		else break;
	}
	return result;
}

int main () {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string line;
		cin >> line;
		State it = line.begin();
		cout << expression(it) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

string s;
int iter;

ll dfs();

ll dfs2(ll val,int op){
  ll tmp = 0;
  while(true){
    if('0'<=s[iter]&&s[iter]<='9'){
      tmp *= 10;
      tmp += s[iter]-'0';
    }else if(s[iter]=='('){
      ++iter;
      if(op) val *= dfs();
      else val /= dfs();
    }else if(s[iter]==')' || s[iter]=='=' || s[iter]=='+' || s[iter]=='-'){
      if(op) val *= tmp;
      else val /= tmp;
      --iter;
      return val;
    }else if(s[iter]=='*' || s[iter]=='/'){
      if(op) val *= tmp;
      else val /= tmp;
      op = s[iter]=='*'?1:0;
      tmp = 0;
    }
    if(iter>=s.size()){
      --iter;--iter;
      return val;
    }
    ++iter;
  }
}

ll dfs(){
  ll val = 0;
  ll tmp = 0;
  int op = 1; // op==1?'+':'-'
  while(true){
    if('0'<=s[iter]&&s[iter]<='9'){
      tmp *= 10;
      tmp += s[iter]-'0';
    }else if(s[iter]=='('){
      ++iter;
      val = op*dfs();
    }else if(s[iter]==')' || s[iter]=='='){
      val += op*tmp;
      tmp = 0;
      if(s[iter]==')')++iter;
      return val;
    }else if(s[iter]=='+'){
      val += op*tmp;
      tmp = 0;
      op = 1;
    }else if(s[iter]=='-'){
      val += op*tmp;
      tmp = 0;
      op = -1;
    }else if(s[iter]=='*' || s[iter]=='/'){
      ++iter;
      val += op*dfs2(tmp,s[iter-1]=='*'?1:0);
      tmp = 0;
    }
    ++iter;
  }
}

int main(){
  int n;
  cin>>n;
  while(n--){
    cin>>s;
    iter = 0;
    cout<<dfs()<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<sstream>

std::string a;
std::vector<std::string>v;
std::vector<std::string>va;
std::stack<std::string>s;
int i=0;

void bun(){
	int ii=0,k=0;
	for(int jj=0;jj<a.size();jj++){
		if(a[jj]=='+'||a[jj]=='-'||a[jj]=='*'||a[jj]=='/'||a[jj]==')'){
			if(a[jj-1]!=')'){
				v.push_back("1");
				std::stringstream z;
				z<<a.substr(ii,jj-ii);
				z>>v[k];
				k++;
				ii=jj+1;
			}
			v.push_back("1");
			v[k]=a[jj];
			k++;
		}else if(a[jj]=='('){
			v.push_back("1");
			v[k]=a[jj];
			k++;
			ii=jj+1;
		}else if(jj==a.size()-1){
			v.push_back("1");
			jj++;
			std::stringstream z;
			z<<a.substr(ii,jj-ii);
			z>>v[k];
		}
	}
}

std::string change(double p){
	std::stringstream z;
	std::string str;
	z<<p;
	z>>str;
	return str;
}

void por(int p,int q,int si){
	int m=0,ma=0;
	for(int k=p;k<=q;k++){
		if(v[k]==")"){}
		else if(v[k]=="("){
			int ky,z=1;
			for(ky=k+1;ky<=q;ky++){
				if(v[ky]=="(")z++;
				if(v[ky]==")")z--;
				if(z==0)break;
			}
			por(k+1,ky-1,s.size());
			k=ky;
		}else if(v[k]!="+"&&v[k]!="-"&&v[k]!="*"&&v[k]!="/"){
			va.push_back("1");
			va[i]=v[k];
			i++;
		}else if(v[k]=="+"||v[k]=="-"||v[k]=="*"||v[k]=="/"){
			if(v[k]=="+")ma=1;
			if(v[k]=="-")ma=1;
			if(v[k]=="*")ma=2;
			if(v[k]=="/")ma=3;
			while(ma<=m&&s.size()>si){
				va.push_back("1");
				va[i]=s.top();
				s.pop();
				i++;
				if(s.size()>=1){
					if(s.top()=="+")m=1;
					if(s.top()=="-")m=1;
					if(s.top()=="*")m=2;
					if(s.top()=="/")m=3;
				}else break;
			}
			s.push(v[k]);
			m=ma;
		}if(k==q){
			while(s.size()>si){
				va.push_back("1");
				va[i]=s.top();
				s.pop();
				i++;
			}
		}
	}
}

std::string calc(){
	std::stack<std::string>sa;
	for(int k=0;k<va.size();k++){
		if(va[k]!="+"&&va[k]!="-"&&va[k]!="*"&&va[k]!="/")sa.push(va[k]);
		else{
			std::stringstream z;
			std::stringstream zz;
			double x,y;
			z<<sa.top();
			z>>x;
			sa.pop();
			zz<<sa.top();
			zz>>y;
			sa.pop();
			if(va[k]=="+")sa.push(change(y+x));
			if(va[k]=="-")sa.push(change(y-x));
			if(va[k]=="*")sa.push(change(y*x));
			if(va[k]=="/")sa.push(change(y/x));
		}
	}
	return sa.top();
}

int main(){
	std::stringstream z;
	double ans;
	std::cin>>a;
	a.pop_back();
	bun();
	por(0,v.size()-1,0);
	z<<calc();
	z>>ans;
	std::cout<<ans<<std::endl;
	return 0;
}

C++: n=gets.to_i;n.times{puts eval gets[0..-3]}