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 <stdlib.h>
#include <string>
#include <vector> 
#include <cstring>
#include <stack>
#include <iostream>
using namespace std;

//¶ñÌ¡»
void strcpy(char*a,char*b){
	while(*a++=*b++);
}

//¶ñÌXy[Xð·×Äæè­
void trim(char*str){
	if(' '==*str) strcpy(str,str+1);
	if(*str++) trim(str);
}

//¶ñðg[N²ÆÉØèoµ
void token(char*str,std::vector<std::string>*data){
	char pos;
	std::string strpos="";
	while(pos=*str++){
		switch (pos){
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			strpos=strpos+pos;
			break;
		case '+':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("+");
			break;
		case '-':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("-");
			break;
		case '*':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("*");
			break;
		case '/':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("/");
			break;
		case '(':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back("(");
			break;
		case ')':
			if(strpos!="") data->push_back(strpos);
			strpos="";
			data->push_back(")");
			break;
		default:
			break;
		}
	}
	if(strpos!="") data->push_back(strpos);
}

//g[NÅ é©mF
bool isToken(std::string str){
	if(str=="+" || str=="-" || str=="*" || str=="/") return true;
	return false;
}

//g[NÌ®`·é
void tokenAna(std::vector<std::string>*in,std::vector<std::string>*out){
	if(isToken((*in)[0])){
		(*in)[1]=(*in)[0]+(*in)[1];
	}else{
		out->push_back((*in)[0]);
	}

	for(int i=1;i<in->size();i++) {
		if(isToken((*in)[i])){
			if(isToken((*in)[i-1])){
				(*in)[i+1]=(*in)[i]+(*in)[i+1];
			}else{
				if((*in)[i-1]=="("){
					(*in)[i+1]=(*in)[i]+(*in)[i+1];
				}else{
					out->push_back((*in)[i]);
				}
			}
		}else{
			out->push_back((*in)[i]);
		}
	}
}



//t|[h@ÉÏ··é½ßÌZqÌDæÊðè
int Priority(const char*str){
	if(0==strcmp(str,"+")) return 10;
	if(0==strcmp(str,"-")) return 10;
	if(0==strcmp(str,"*")) return 20;
	if(0==strcmp(str,"/")) return 20;
	return 0;
}

//®ðt|[h@ÉÏ·
void Analyzer(std::vector<std::string>*data,std::vector<std::string>*out,int*i){
	std::stack<const char*> stack;

	for(;*i<data->size();(*i)++){
		if((*data)[*i]=="+" || (*data)[*i]=="-" || (*data)[*i]=="*" || (*data)[*i]=="/"){
			while(stack.empty()==false && //false : X^bNÉlª é
				!(Priority((*data)[*i].c_str())>Priority(stack.top()))){ 
					const char*str=stack.top();//ÅãöÌlÌæ¾
					stack.pop();//ÅãöÌlÌí
					out->push_back(str);
			}
			stack.push((*data)[*i].c_str());//lÌÇÁ
		}else{
			if((*data)[*i]=="("){
				*i=*i+1;
				Analyzer(data,out,i);
			}else{
				if((*data)[*i]==")"){
					goto end;
				}else{
					out->push_back((*data)[*i]);
				}
			}
		}
	}
end:
	while(stack.empty()==false){//false : X^bNÉlª é
		const char*str=stack.top();//ÅãöÌlÌæ¾
		stack.pop();//ÅãöÌlÌí
		out->push_back(str);
	}
}

//t|[h@\LÌvZ®ðvZ
double calc(std::vector<std::string>*out){
	int c=out->size();
	std::stack<double> stack;
	double j,k;
	for(int i=0;i<c;i++){
			if((*out)[i]== "+"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k+j);
			}else if((*out)[i]=="-"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k-j);
			}else if((*out)[i]=="*"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k*j);
			}else if((*out)[i]=="/"){
				j=stack.top();
				stack.pop();
				k=stack.top();
				stack.pop();
				stack.push(k/j);
			}else{
				stack.push(atof((*out)[i].c_str()));
			}
		}
	return stack.top();
}

int main(){
//	printf("%s\n","((-10+-20)*((30+40))+1)*2 [Enter] ÌlÉüÍµÄ­¾³¢");
//	printf("--------------------------------------\n");
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		std::vector<std::string> data;
		std::vector<std::string> out;

		//¶ñÆµÄüÍ
		char str[1024];
		scanf("%s",str);
		trim(str);
		token(str,&data);
		
		std::vector<std::string> data2;
		tokenAna(&data,&data2);

		//{printf("g[NØèoµÊ : ");for(int a=0;a<data2.size();a++) printf("%s ",data2[a].c_str());}
		
		int c=0;
		Analyzer(&data2,&out,&c);

		//{printf("\nt|[h@ÉÏ· : ");for(int a=0;a<out.size();a++) printf("%s ",out[a].c_str());}
		//printf("\nvZÊ : ");
		printf("%g\n",calc(&out));
		//printf("--------------------------------------\n");
	}
	return 0;
}

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

int factor(State &begin);

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 expression(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 factor(State &begin)
{
	int ret;

	if(*begin == '(')
	{
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	{
		ret = number(begin);
	}

	return ret;
}


int main()
{
	int n;
	cin >> n;
	cin.ignore();
	while(n--)
	{
		string s;
		getline(cin,s);

		State begin = s.begin();
		int ans = expression(begin);
		cout << ans << endl;
	}
	return 0;
}

C++: #include<string>
#include<cctype>
#include<stdio.h>
using namespace std;
int ex(char **b);
int te(char **b);
int fu(char **b);
int num(char **b);
int main(){
	int n;
	char s[1000];
	scanf("%d\n",&n);
	while(n--){
		scanf("%s",s);
		char *p = s;
		printf("%d\n",ex(&p));
	}
}


//和差
int ex(char **b){
	int r=te(b);
	for(;;){
		if(**b=='+')r+=te(&(++*b));
		else if(**b=='-')r-=te(&(++*b));
		else break;
	}
	return r;
}
//乗除
int te(char **b){
	int r=fu(b);
	for(;;){
		if(**b=='*')r*=fu(&(++*b));
		else if(**b=='/')r/=fu(&(++*b));
		else break;
	}
	return r;
}
//数字
int num(char **b){
	int r=0,cnt=0;
	while(isdigit(**b)){
		r*=10;
		r+=**b-'0';
		++*b;
		cnt++;
	}
	return r;
}
//括弧
int fu(char **b){
	if(**b=='('){
		int r=ex(&(++*b));
		++*b;
		return r;
	}
	else return num(b);
}