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 <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

struct RevPolElement
{
	RevPolElement(int type, int n) : type(type), n(n) { }
	int type;
	int n;
};

deque<RevPolElement> make_revpol(char* s)
{
	map<char, int> pr;
	pr['w'] = -1;
	pr['('] = 0;

	pr['+'] = pr['-'] = 1;
	pr['*'] = pr['/'] = 2;

	deque<RevPolElement> res;
	stack<char> t;
	t.push('w');
	for (int i = 0; s[i] != '='; ++i)
	{
		if (isdigit(s[i]))
		{
			int t = s[i] - '0';
			while (isdigit(s[i+1]))
				t = t*10 + s[i++] - '0';
			res.push_back(RevPolElement(0, t));
		}
		else
		{
			char op = s[i];
			if (op == ')')
			{
				while (true)
				{
					char topOp = t.top();
					t.pop();
					if (topOp == '(')
						break;
					res.push_back(RevPolElement(1, topOp));
				}
			}
			else if (op == '(')
				t.push(op);
			else
			{
				while (pr[op] <= pr[t.top()])
				{
					res.push_back(RevPolElement(1, t.top()));
					t.pop();
				}
				t.push(op);
			}
		}
	}
	while (t.size() > 1)
	{
		res.push_back(RevPolElement(1, t.top()));
		t.pop();
	}

	return res;
}

int calculate_revpol(deque<RevPolElement> revpol)
{
	stack<int> t;
	while (!revpol.empty())
	{
		if (revpol.front().type)
		{
			char op = revpol.front().n;
			int a, b;
			b = t.top(); t.pop();
			a = t.top(); t.pop();
			int c;
			if (op == '+')
				c = a + b;
			else if (op == '-')
				c = a - b;
			else if (op == '*')
				c = a * b;
			else if (op == '/')
				c = a / b;

			t.push(c);
		}
		else
			t.push(revpol.front().n);

		revpol.pop_front();
	}

	return t.top();
}

int main()
{
	int n;
	while (cin >> n)
	{
		cin.get();
		while (n--)
		{
			char buf[256];
			cin.getline(buf, sizeof(buf));
			printf("%d\n", calculate_revpol(make_revpol(buf)));
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

struct S{
	string s;
	int i;
	char nx(){
		return s[i];
	}
	bool dig(){
		return '0'<=nx()&&nx()<='9';
	}
	void inc(){i++;}
};

int expr(S&);
int term(S&);
int fact(S&s);
int num(S&);

int expr(S&s){
	int a=term(s);
	while(1){
		if(s.nx()=='+'){
			s.inc();
			a+=term(s);
		}else if(s.nx()=='-'){
			s.inc();
			a-=term(s);
		}else
			break;
	}
	return a;
}

int fdiv(int a,int b){
	return a/b-((a^b)<0&&a%b);
}

int term(S&s){
	int a=fact(s);
	while(1){
		if(s.nx()=='*'){
			s.inc();
			a*=fact(s);
		}else if(s.nx()=='/'){
			s.inc();
			a/=fact(s);
			//a=fdiv(a,fact(s));
		}else
			break;
	}
	return a;
}

int fact(S&s){
	if(s.nx()=='('){
		s.inc();
		int a=expr(s);
		s.inc();
		return a;
	}else{
		int a=0;
		while(s.dig()){
			a=a*10+s.nx()-'0';
			s.inc();
		}
		return a;
	}
}

void slv(){
	S s;
	cin>>s.s;
	s.i=0;
	cout<<expr(s)<<endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	rep(_,n)slv();
}

C++: #include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
int n;
string str;
int start,goal;
void kake();
void tasi();
void tume(int,int);
int Getnum1(int);
int Getnum2(int);
string i2s(int);

string i2s(int num){
  stringstream ss;
  string str;
  ss << num;
  ss >> str;
  return str;
}

int Getnum1(int i){

  string num = "";
  while(1){
    if(!('0'<=str[i] && str[i] <='9')||0 > i)break;
    num+=str[i];
    str[i] = '#';
    i--;
  }
  //  cout << str << endl;
  //  cout << "num "<<num << endl;
  reverse(num.begin(),num.end());
  return atoi(num.c_str());
}

int Getnum2(int i){

  string num = "";
  while(1){
    if(!('0'<=str[i] && str[i] <='9')||str.size() < i)break;
    num+=str[i];
    str[i] = '#';
    i++;
  }
  return atoi(num.c_str());
}

void tume(int s,int g){
  string str2="";
  for(int i = 0 ; i < str.size() ; i++){
    if(str[i] != '#'&& (s != i || g != i))str2+=str[i];
  }
  str= str2;
}

void cal(){
  kake();
  tasi();
}

void kake(){
  for(int i = start ; i <= goal ; i++ ){
    //    cout << start << ' ' << goal<<endl;
    if(str[i] == '*'){
      int t1 = Getnum1(i-1);
      int t2 = Getnum2(i+1);
      int t = t1*t2;
      int len1 = i2s(t1).size();
      int len2 = i2s(t2).size();
      int len3 = i2s(t).size();
      str.replace(i-len1,i+len2-start,i2s(t));
      tume(i-1,i+1);
      //
      //      cout << str << endl;
      i = start;
      goal = goal-((len1+len2+1)-len3);
      //      cout << "goal "<<goal << endl;
    }
    if(str[i] == '/'){
      int t1 = Getnum1(i-1);
      int t2 = Getnum2(i+1);
      int t = t1/t2;
      int len1 = i2s(t1).size();
      int len2 = i2s(t2).size();
      int len3 = i2s(t).size();
      str.replace(i-len1,i+len2-start,i2s(t));
      tume(i-1,i+1);
      //
      i = start;
      goal = goal-((len1+len2+1)-len3);
      //      cout << "goal "<<goal << endl;
    }
  }
}
void tasi(){
  for(int i = start ; i <= goal ; i++ ){
    if(str[i] == '+'){
      int t1 = Getnum1(i-1);
      int t2 = Getnum2(i+1);
      int t = t1+t2;
      int len1 = i2s(t1).size();
      int len2 = i2s(t2).size();
      int len3 = i2s(t).size();
      str.replace(i-len1,i+len2-start,i2s(t));
      tume(i-1,i+1);
      //
      i = start;
      goal = goal-((len1+len2+1)-len3);
      //      cout << "goal "<<goal << endl;
    }
    if(str[i] == '-'){
      int t1 = Getnum1(i-1);
      int t2 = Getnum2(i+1);
      int t = t1-t2;
      int len1 = i2s(t1).size();
      int len2 = i2s(t2).size();
      int len3 = i2s(t).size();
      str.replace(i-len1,i+len2-start,i2s(t));
      tume(i-1,i+1);
      //      cout << '-' << endl;      cout << str << endl;
      i = start;
      goal = goal-((len1+len2+1)-len3);
    }
  }
}

int main(){
  cin >> n;
  while(n--){
    str = "";
    cin >> str;

    if(str[0] == '#')break;

    for(int i = 0 ; i < str.size() ; i++){
      if(str[i] == '(')start = i;
      if(str[i] == ')'){
	goal = i;
	cal();
	str[start] = '#';
	str[goal] = '#';
	tume(start,goal);
	i = -1;
	continue;
      }
    }
    start = 0,goal = str.size()-1;
    cal();
    int ans = atoi(str.c_str());
    cout << ans << endl;
  }
  return 0;
}