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<string>
#include<algorithm>
#include<sstream>
#include<cstring>

void erase(std::vector<std::string>&v,int e,int f){
	for(int i=e;i<v.size()-f;i++)v[i]=v[i+f];
}

std::string solve(std::string str){
	std::vector<std::string>v;
	int a,b,c,d,v_size,j=0;
	for(int i=0;i<=str.size();i++){
		if(i==str.size()||str[i]=='+'||str[i]=='-'||str[i]=='*'||str[i]=='/'){
			v.push_back(str.substr(j,i-j));
			v.push_back(str.substr(i,1));
			j=i+1;
		}
	}
	v_size=v.size();
	a=std::find(v.begin(),v.begin()+v_size,"*")-v.begin();
	while(a!=v_size){
		int p=std::stoi(v[a-1]),q=std::stoi(v[a+1]);
		std::stringstream z;
		z<<p*q;z>>v[a-1];
		erase(v,a,2);v_size-=2;
		a=std::find(v.begin(),v.begin()+v_size,"*")-v.begin();
	}
	b=std::find(v.begin(),v.begin()+v_size,"/")-v.begin();
	while(b!=v_size){
		int p=std::stoi(v[b-1]),q=std::stoi(v[b+1]);
		std::stringstream z;
		z<<p/q;z>>v[b-1];
		erase(v,b,2);v_size-=2;
		b=std::find(v.begin(),v.begin()+v_size,"/")-v.begin();
	}
	c=std::find(v.begin(),v.begin()+v_size,"+")-v.begin();
	while(c!=v_size){
		int p=std::stoi(v[c-1]),q=std::stoi(v[c+1]);
		std::stringstream z;
		z<<p+q;z>>v[c-1];
		erase(v,c,2);v_size-=2;
		c=std::find(v.begin(),v.begin()+v_size,"+")-v.begin();
	}
	d=std::find(v.begin(),v.begin()+v_size,"-")-v.begin();
	while(d!=v_size){
		int p=std::stoi(v[d-1]),q=std::stoi(v[d+1]);
		std::stringstream z;
		z<<p-q;z>>v[d-1];
		erase(v,d,2);v_size-=2;
		d=std::find(v.begin(),v.begin()+v_size,"-")-v.begin();
	}
	return v[0];
}

int main(){
	int n;
	std::string str;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>str;
		int a=str.find('('),b=str.find(')');
		while(a!=-1){
			std::string astr=str.substr(a+1,(b-1)-a);
			str.erase(a,b-a+1);
			str.insert(a,solve(astr));
			a=str.find('('),b=str.find(')');
		}
		std::cout<<solve(str.substr(0,str.size()-1))<<std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

const double eps=1e-6;
double add(double a,double b){
    if(abs(a+b)<eps)return 0;
    return a+b;
}

typedef pair<double,double> P;
P operator+(const P& x,const P& y){
    return {add(x.first,y.first),add(x.second,y.second)};
}

P operator-(const P& x,const P& y){
    return {add(x.first,-y.first),add(x.second,-y.second)};

}

P operator*(const P& x,const double& y){
    return {x.first*y,x.second*y};
}
double dot(P x,P y){
    return add(x.first*y.first,x.second*y.second);


}

double det(P x,P y){
    return add(x.first*y.second,-x.second*y.first);
}

bool onseg(P p1,P p2,P q){
    return det(p1-q,p2-q)==0 &&dot(p1-q,p2-q)<=0; 
}

P intersection(P p1,P p2,P q1,P q2){
    return p1+(p2-p1)*(det(q2-q1,q1-p1)/det(q2-q1,p2-p1));
}

bool cross(P p1,P p2,P q1,P q2){
    if(det(p1-p2,q1-q2)==0)return onseg(p1,p2,q1)||onseg(p1,p2,q2)||onseg(q1,q2,p1)||onseg(q1,q2,p2);
    P ret=intersection(p1,p2,q1,q2);
    return onseg(p1,p2,ret)&&onseg(q1,q2,ret);
}

double dist(P p1,P p2,P q){
    if(dot(q-p1,p2-p1)<=0)return sqrt(dot(q-p1,q-p1));
    if(dot(q-p2,p1-p2)<=0)return sqrt(dot(q-p2,q-p2));
    P d=p1-p2;
    P ret=q+P{d.second,-d.first};
    P h=intersection(p1, p2, q, ret);
    return sqrt(dot(q-h,q-h));
}
double d(P p,P q){
    return sqrt(dot(p-q,p-q));
}

int main(){
    int n;
    vector<int>ans;
    while(cin>>n,n!=0){
        P a[n];
        double r[n];
        rep(i,n)cin>>a[i].first>>a[i].second>>r[i];
        P b[n-1][2];
        rep(i,n-1){
            P v=(a[i+1]-a[i])*(1.0/d(a[i+1],a[i]));
            P h={v.second,-v.first};
            double l=(r[i]*r[i]+d(a[i],a[i+1])*d(a[i],a[i+1])-r[i+1]*r[i+1])/2/d(a[i],a[i+1]);
            b[i][0]=a[i]+v*l+h*sqrt(r[i]*r[i]-l*l);
            b[i][1]=a[i]+v*l-h*sqrt(r[i]*r[i]-l*l);
        }
        double x[2*n][2*n];
        rep(i,2*n)rep(j,2*n)x[i][j]=inf;
        rep(i,n-1)rep(j,2){
            bool ok=true;
            rep(k,i)if(!cross(a[0],b[i][j],b[k][0],b[k][1]))ok=false;
            if(ok)x[0][2*i+j+1]=d(a[0],b[i][j]);
        }
        rep(i,n-1)rep(j,2){
            bool ok=true;
            REP(k,i+1,n-1)if(!cross(a[n-1],b[i][j],b[k][0],b[k][1]))ok=false;
            if(ok)x[2*n-1][2*i+j+1]=d(a[n-1],b[i][j]);
        }
        rep(i,n-1)REP(j,i+1,n-1)rep(k,2)rep(l,2){
            bool ok=true;
            REP(m,i+1,j)if(!cross(b[i][k],b[j][l],b[m][0],b[m][1]))ok=false;
            if(ok)x[2*i+k+1][2*j+l+1]=d(b[i][k],b[j][l]);
        }
        bool ok=true;
        rep(i,n-1)if(!cross(a[0],a[n-1],b[i][0],b[i][1]))ok=false;
        if(ok)x[0][2*n-1]=d(a[0],a[n-1]);
        rep(i,2*n)x[i][i]=0;
        rep(i,n)x[2*i+1][2*i+2]=d(b[i][0],b[i][1]);
        rep(i,2*n)rep(j,2*n)x[i][j]=min(x[i][j],x[j][i]);
        rep(i,2*n)rep(j,2*n)rep(k,2*n)x[j][k]=min(x[i][j]+x[i][k],x[j][k]);
        cout<<setprecision(10)<<x[0][2*n-1]<<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;
			if(xr!=s.size()-1) 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;
			if(xr!=s.size()-1) 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){
		if(xr==s.size()-1) return foo1(s.substr(0,xl)+foo2(s.substr(xl+1,xr-xl-1)));
		return foo1(s.substr(0,xl)+foo2(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;
	}
}