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 <cstdio>
#include <vector>
#include <string>
#include <deque>
#include <memory.h>

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)

#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)

using namespace	std;

class CCalc
{
	string	s_;
	int	pos_;
	
	int	IsDigit(int x)	{	return(x <= '9' && x >= '0');	}
	void	SkipSpace()
	{
		cout << "Skipping...";
		for(int c = s_[pos_]; (c == ' ' || c == '\t') && pos_ < s_.size(); pos_ ++);
		cout << "OK" << endl;
	}
	int	Number()
	{
		int num = 0;
		while(IsDigit(s_[pos_]))	{	num	= num * 10 + s_[pos_ ++] - '0';	}
		return(num);
	}
	int	Factor()
	{
		int val;
		if(pos_ >= s_.size())	{	cout << "warning: Out of bounds!" << endl;	}
		if(IsDigit(s_[pos_]))
		{
			val = Number();
			return(val);
		}
		pos_ ++;
		val	= Expr();
		pos_ ++;
		return(val);
	}
	int	Term()
	{
		int	val1	= Factor();
		while(s_[pos_] == '*' || s_[pos_] == '/')
		{
			char	op	= s_[pos_ ++];
			int val2	= Factor();
			switch(op)
			{
				case '*':	val1 *= val2;	break;
				case '/':	val1 /= val2;	break;
			}
		}
		return(val1);
	}
	int	Expr()
	{
		int	val1	= Term();
		while(s_[pos_] == '+' || s_[pos_] == '-')
		{
			char	op	= s_[pos_ ++];
			int val2	= Term();
			switch(op)
			{
				case '+':	val1 += val2;	break;
				case '-':	val1 -= val2;	break;
			}
		}
		return(val1);
	}
	
public:
	int	Eval(string &expression)
	{
		pos_	= 0;
		int pos = 0;
		s_.resize(expression.size());
		rep(i, expression.size())
		{
			if(expression[i] != ' ')
			{	s_[pos ++] = expression[i];	}
		}
		return(Expr());
	}
};

int main()
{
	CCalc	calc;
	string	expression;
	int tc;
	
	for(cin >> tc, cin.ignore(); tc > 0; tc --)
	{
		getline(cin, expression);
		cout << calc.Eval(expression) << endl;
	}
	
//	while(getline(cin, expression), expression.size())
//	{	::printf("%s = %d\n", expression.c_str(), calc.Eval(expression));	}
}

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

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 <cstdio>
#include <cctype>
#include <string>

class Parser {
public:
  std::string str;
  int idx;
  Parser (std::string str):str(str),idx(0)
  {
  }
  int evalas();
  int evalmd();
  int evalexpr();
  int evalnum();
};

int Parser::evalas() {
  //  printf("evalas begin: idx=%d\n",idx);

  int left = evalmd(), right;
  while(true) {
    switch(str[idx]) {
    case '+':
      idx++;
      right = evalmd();
      left = left+right;
      break;
    case '-':
      idx++;
      right = evalmd();
      left = left-right;
      break;
    default:
      goto hoge;
    }
  }
 hoge:

  //  printf("evalas end: idx=%d\n",idx);
  return left;
}

int Parser::evalmd() {
//  printf("evalmd begin: idx=%d\n",idx);  

  int left = evalexpr(),right;
  while(true) {
    switch(str[idx]) {
    case '*':
      idx++;
      right = evalexpr();
      left = left*right;
      break;
    case '/':
      idx++;
      right = evalexpr();
      left = left/right;
      break;
    default:
      goto hoge;
    }
  }
 hoge:
  //  printf("evalmd end: idx=%d\n",idx);  
  return left;
}

int Parser::evalexpr() {
  //  printf("evalexpr: idx=%d\n",idx);

  int n;
  if (str[idx] == '(') {
    idx++;
    n = evalas();
    idx++;
  } else {
    n = evalnum();
  }
//  printf("returned: %d\n",n);
  return n;
}

int Parser::evalnum() {
  //  printf("evalnum begin: idx=%d\n",idx);

  int ans=0;
  char ch;
  while (isdigit(ch=str[idx])) {
    idx++;
    ans = ans*10+(int)ch-(int)'0';
  }

  //  printf("evalnum　end: idx=%d\n",idx);
  return ans;
}

int main() {
  int time;
  scanf("%d\n",&time);

  while(time--) {
    char str[100];
    fgets(str,100,stdin);
    //    printf("expr: %s\n",str);
    printf("%d\n",Parser(std::string(str)).evalas());
  }
}