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<string>
#include<vector>

#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
using ll = long long;
using namespace std;

ll calculate_expression_without_brackets(const string&exprwb)
{
	auto my_stoll = [](const string&str) {
		if (str[0] != '-') {
			return stoll(str);
		} else {
			for (ll i = 0;; ++i) {
				if (str[i] != '-') {
					return stoll(str.substr(i - i % 2));
				}
			}
		}
	};
	vector<ll>arg;
	vector<char>opr;
	ll head = 0;
	REP1(i, exprwb.size() - 2) {
		if (exprwb[i] == '+' || exprwb[i] == '-' && i != 0 && [](char c) {return '0' <= c && c <= '9'; }(exprwb[i - 1]) || exprwb[i] == '*' || exprwb[i] == '/') {
			arg.push_back(my_stoll(exprwb.substr(head, i - head)));
			opr.push_back(exprwb[i]);
			head = i + 1;
		}
	}
	arg.push_back(my_stoll(exprwb.substr(head)));
	if (arg.size() == 1) {
		return arg[0];
	} else {
		for (ll i = 0; i < opr.size(); ++i) {
			if (opr[i] == '*') {
				arg[i] *= arg[i + 1];
				arg.erase(arg.begin() + i + 1);
				opr.erase(opr.begin() + i);
				--i;
			} else if (opr[i] == '/') {
				arg[i] /= arg[i + 1];
				arg.erase(arg.begin() + i + 1);
				opr.erase(opr.begin() + i);
				--i;
			}
		}
		if (arg.size() == 1) {
			return arg[0];
		} else {
			for (ll i = 0; i < opr.size(); ++i) {
				if (opr[i] == '+') {
					arg[i] += arg[i + 1];
					arg.erase(arg.begin() + i + 1);
					opr.erase(opr.begin() + i);
					--i;
				} else if (opr[i] == '-') {
					arg[i] -= arg[i + 1];
					arg.erase(arg.begin() + i + 1);
					opr.erase(opr.begin() + i);
					--i;
				}
			}
			return arg[0];
		}
	}
}
string calculate_expression(const string&expr) {
	ll open = expr.find('(');
	if (open != string::npos) {
		ll close = [expr, open]() {
			ll cnt = 0;
			for (ll i = open + 1;; ++i) {
				if (expr[i] == '(') {
					++cnt;
				} else if (expr[i] == ')') {
					if (cnt == 0) {
						return i;
					}
					--cnt;
				}
			}
		}();
		return calculate_expression(expr.substr(0, open) + calculate_expression(expr.substr(open + 1, close - open - 1)) + expr.substr(close + 1));
	} else {
		return to_string(calculate_expression_without_brackets(expr));
	}
}
signed main()
{
	ll n;
	cin >> n;
	for (ll i = 0; i < n; ++i) {
		string expr;
		cin >> expr;
		expr.pop_back();
		cout << calculate_expression(expr) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int exp();
int term();
int factor();
int number();
int digit();
int p=0;
string str;
int main(){
  int n,re;
  cin >> n;
  while(n){
    p=0;
    cin >> str;
    re=exp();
    cout << re << endl;
    n--;
  }
  return 0;
}
int exp(){
  int val=term();
  while(str[p]=='+'||str[p]=='-'){
    if(str[p]=='+'){
      p++;
      val+=term();
    }else if(str[p]=='-'){
      p++;
      val-=term();
    }
  }
  return val;
}
int term(){
  int val=factor();
  while(str[p]=='*'||str[p]=='/'){
    if(str[p]=='*'){
      p++;
      val*=factor();
    }else if(str[p]=='/'){
      p++;
      val/=factor();
    }
  }
  return val;
}
int factor(){
  int val;
  if(str[p]=='('){
    p++;
    val=exp();
    p++;
  }else{
      val=digit();
  }
  return val;
}
int number(){
  int val=digit();
  return val;
}
int digit(){
  int ret,cnt=0;
  while(1){
    if(cnt==0&&'0'<=str[p]&&str[p]<='9'){
      ret=str[p]-'0';
      p++;
      cnt=1;
    }
    else if(cnt==1&&'0'<=str[p]&&str[p]<='9'){
      ret=ret*10+(str[p]-'0');
      p++;
    }
    else{
      break;
    }
  }
  /*  if('0' <= str[p] && str[p] <= '9') {
    if(cnt==0){
      ret=str[p]-'0';
      cnt=1;
    }
    p++;
    if('0' <= str[p] && str[p] <= '9') {
      ret=ret*10+(str[p]-'0');
      digit();
    }
    return ret;
    }*/
  return ret;
}

C++: #include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>

int parse_int(std::string const& s, size_t& i) {
  int res = s[i]-'0';
  while (isdigit(s[++i]))
    res = res*10 + s[i]-'0';
  return res;
}

int apply(int lhs, char op, int rhs) {
  if (op == '+') return lhs + rhs;
  if (op == '-') return lhs - rhs;
  if (op == '*') return lhs * rhs;
  if (op == '/') return lhs / rhs;
  assert(false);
}

const std::vector<std::string> ops = {"+-", "*/"};
int parse(std::string const& s, size_t& i, size_t preced = 0) {
  if (ops.size() == preced) {
    if (isdigit(s[i])) return parse_int(s, i);
    if (s[i] == '(') {
      int res = parse(s, ++i, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    assert(false);
  }
  int res = parse(s, i, preced+1);
  while (i < s.length()) {
    char op = s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    res = apply(res, op, parse(s, ++i, preced+1));
  }
  return res;
}

int main() {
  size_t n;
  scanf("%zu", &n);

  for (size_t i = 0; i < n; ++i) {
    char buf[1024];
    scanf("%s", buf);
    std::string s = buf;
    if (s.back() != '=') {
      printf("%s\n", s.c_str());
      continue;
    }

    size_t j = 0;
    printf("%d\n", parse(s, j));
  }
}

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

char s[200];
char *p;

int E();
int F();
int T();
int N();

#ifdef DEBUG
#define dump(s) cerr << s << endl
#else
#define dump(...)
#endif

int E(){
    int res = F();
    while(*p=='+' || *p=='-'){
        if(*p=='+') p++, res += F();
        else if(*p=='-') p++, res -= F();
    }
    return res;
}

int F(){
    int res = T();
    while(*p=='*' || *p=='/'){
        if(*p=='*') p++, res *= T();
        else if(*p=='/') p++, res /= T();
    }
    dump(res);
    return res;
}

int T(){
    int res;
    if(*p=='(') p++, res = E(), p++;
    else res = N();
    return res;
}

int N(){
    int res = 0;
    while(isdigit(*p)){
        res = res*10 + *p - '0';
        p++;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        p = s;
        cout << E() << endl;
    }
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
using namespace std;

typedef string::const_iterator State;
class ParseError{};

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=='*')ret*=factor(++begin);
        else if(*begin=='/')ret/=factor(++begin);
        else break;
    }
    return ret;
}

int expression(State &begin){
    int ret=term(begin);

    while(true){
        if(*begin=='+')ret+=term(++begin);
        else if(*begin=='-')ret-=term(++begin);
        else break;
    }
    return ret;
}

int factor(State &begin){
    if(*begin=='('){
        int ret=expression(++begin++);
    }else{
        return number(begin);
    }
}





int main(){

    int N;
    cin>>N;
    cin.ignore();
    REP(i,N){

        string s;
        getline(cin,s);
        State begin = s.begin();
        cout<<expression(begin)<<endl;

    }

    return 0;
}