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 <string>
#include <cstring>
#include <cstdlib>
#include <stack>
#include <vector>
#include <cctype>
#include <cmath>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

void calc(string st, stack<double> &s) {	
	if(st == "*") {
		double a = s.top();
		s.pop();
		double b = s.top();
		s.pop();
		s.push(floor(a * b));
	} else if(st == "+") {
		double a = s.top();
		s.pop();
		double b = s.top();
		s.pop();
		s.push(a + b);
	} else if(st == "-") {
		double a = s.top();
		s.pop();
		double b = s.top();
		s.pop();
		s.push(b - a);
	} else if(st == "/") {
		double a = s.top();
		s.pop();
		double b = s.top();
		s.pop();
		s.push(floor(b / a));
	} else {
		s.push(atof(st.c_str()));
	}
}
int getPriority(string s) {
	if(s == "(") {
		return 5;
	} else if(s == "*" || s == "/") {
		return 3;
	} else if(s == "+" || s == "-") {
		return 2;
	} else if(s == ")") { 
		return 1;
	} else return 4;
}

int main() {
	int n;
	cin >> n;
	while(n--) {
		string str;
		cin >> str;
		str.erase(--str.end());
		
		vector<string> v;
		
		int f = 0;
		char prev = '(';
		bool minus = 0;
		rep(i, str.size()) {		
			if(isdigit(str[i])) {
				f++;
			} else {
				if(f) {
					string st;
					if(minus) {
						st += '-';
						minus = 0;
					}
					rep(j,f) {
						st += str[i - f + j];
					}	
					v.push_back(st);
					string st2;
					st2 += str[i];
					v.push_back(st2);
					f = 0;
				} else {
					if(prev == '(' && str[i] == '-') {
						minus = 1;
						prev = str[i];
						continue;
					}
					string st3;
					st3 += str[i];
					v.push_back(st3);
				}
			}
			prev = str[i];
		}
		if(f) {
			string st;
			rep(j,f) {
				st += str[str.size() - f + j];
			}
			v.push_back(st);
		}

		stack<string> s;
		vector<string> nv;
		stack<double> ret;
		int p = 0;
		rep(i,v.size()) {
			cout << v[i] << endl;
		}
		rep(i,v.size()) {
			p = getPriority(v[i]);
			while(!s.empty() && getPriority(s.top()) > p && s.top() != "(") {
				nv.push_back(s.top());
				s.pop();
			}
			if(v[i] == ")") {
				s.pop();
			} else {
				s.push(v[i]);
			}
		}
		while(!s.empty()) {
			nv.push_back(s.top());
			s.pop();
		}
		rep(i,nv.size()) {
			calc(nv[i], ret);
		}
		cout << ret.top() << endl;
	}
	return 0;
}

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

int number(string::const_iterator &c){//number
	int ret = 0;
	while(isdigit(*c)){
		ret*=10;
		ret+=*c-'0';
		c++;
	}
	return ret;
}

int expression(string::const_iterator&);
int factor(string::const_iterator &c) {
	int ret;
	if (*c=='(') {
    	c++;
		ret = expression(c);
		c++;
	}else return number(c);
	return ret;
}

int term(string::const_iterator &c){//*or/
	int ret = factor(c);
	for(;;){
		if(*c=='*'){
			c++;
			ret*=factor(c);
		}else if(*c=='/'){
			c++;
			ret/=factor(c);
		}else break;
	}
	return ret;
}

int expression(string::const_iterator &c){//all
	int ret = term(c);
	for(;;){
		if(*c=='+'){
			c++;
			ret+=term(c);
		}else if(*c=='-'){
			c++;
			ret-=term(c);
		}else break;
	}
	return ret;
}

int main(){
	int n;
	cin>>n;
	cin.ignore();
	while(n--){
		string s;
		getline(cin,s);
		string::const_iterator c=s.begin();
		cout<<expression(c)<<"\n";
	}
	return 0;
}

C++: #include<iostream>
#include<cstdlib>
using namespace std;
typedef pair<int,const char*>parsed;
parsed expr(const char *p);
parsed term(const char *p);
parsed fact(const char *p);
parsed expr(const char *p){
  parsed r=term(p);
 while(*r.second=='+'||*r.second=='-'){
    char op =*r.second;
    int tmp=r.first;
    r=term(r.second+1);
    if(op=='+')r.first=tmp+r.first;
    else r.first=tmp-r.first;
  }
  return r;
}
parsed term(const char *p){
  parsed r=fact(p);
  while(*r.second=='*'||*r.second=='/'){
    char op=*r.second;
    int tmp=r.first;
    r=fact(r.second+1);
    if(op=='*')r.first=tmp*r.first;
    else r.first=tmp/r.first;
  }
  return r;
}
parsed fact(const char *p){
  if(isdigit(*p)){
    int t=*(p++)-'0';
    while(isdigit(*p))t=t*10+*(p++)-'0';
    return parsed(t,p);
  }
  else if(*p=='('){
    parsed r=expr(p+1);
    if(*r.second!=')')exit(0);
    return parsed(r.first,r.second+1);
  }
  else exit(0);
}
main(){
  string str;
  int n;
  cin>>n;
  while(n--){
	  cin>>str;
    cout<<expr(str.c_str()).first<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>

const char *p;
class ParseError {};

int expression();
int term();
int factor();
void consume(char);

int main() {
  using namespace std;

  int n;
  string str;
  int ans;

  cin >> n;
  cin.ignore();
  for(int i = 0; i < n; i++) {
    getline(cin, str);
    p = str.c_str();
    cout << *p << endl;

    ans = expression();
    consume('=');
    cout << ans << endl;
  }
  
  return 0;
}

void consume(char expected) {
  if(*p == expected) {
    p++;
  } else {
    std::cerr << "Expected '" << expected << "' but got '" << *p << "'" << std::endl;
    std::cerr << "Rest string is '";
    while(*p) {
      std::cerr << *p++;
    }
    std::cerr << "'" << std::endl;
    throw ParseError();
  }
}

int factor() {
  int ret;
  char *e;
  
  if(*p == '(') {
    consume('(');
    ret = expression();
    consume(')');
  } else {
    ret = strtol(p, &e, 10);
    p = e;
  }
  
  return ret;
}

int term() {
  int ret = factor();
  
  for(;;) {
    if(*p == '*') {
      p++;
      ret *= factor();
    } else if (*p == '/') {
      p++;
      ret /= factor();
    } else {
      break;
    }
  }

  return ret;
}

int expression() {
  int ret = term();
  
  for(;;) {
    if(*p == '+') {
      p++;
      ret += term();
    } else if (*p == '-') {
      p++;
      ret -= term();
    } else {
      break;
    }
  }
  
  return ret;
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int q,n;
string s;

class Analysis{
	public:
	int Num(int &I){
		int res=0;
		while(I<n&&isdigit(s[I])) res=10*res+(s[I]-'0'),I++;
		return res;
	}
	int Fact(int &I){
		int res;
		if(s[I]=='(') res=Exp(++I),I++;
		else res=Num(I);
		return res;
	}
	int Term(int &I){
		int res=Fact(I);
		while(I<n){
			if(s[I]=='*') res*=Fact(++I);
			else if(s[I]=='/') res/=Fact(++I);
			else break;
		}
		return res;
	}
	int Exp(int &I){
		int res=Term(I);
		while(I<n){
			if(s[I]=='+') res+=Term(++I);
			else if(s[I]=='-') res-=Term(++I);
			else break;
		}
		return res;
	}
};

Analysis A;

int main(){
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>s;
		s.pop_back();
		n=s.size();
		int I=0;
		cout<<A.Exp(I)<<endl;
	}
}