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++: //suhan lee,saitama university

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <complex>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) for(int i=0;i<n;i++)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define pb push_back 
#define pf push_front
int ex1(string input,int& i);
int ex2(string input,int& i);
int ex3(string input,int& i);
int exnum(string input,int& i);
int ex1(string input,int& i){
  int a;
  a=ex2(input,i);
  if(input[i]=='+')
    return a+ex1(input,++i);
  else if(input[i]=='-')
    return a-ex1(input,++i);
  else return a;
}
int ex2(string input,int& i){
  int a=ex3(input,i);
  if(input[i]=='*')
    return a*ex2(input,++i);
  else if(input[i]=='/')
    return a/ex2(input,++i);
  else return a;
}
int ex3(string input,int& i){
  int a;
  if(input[i]=='('){
    a=ex1(input,++i);
    i++;
  }
  else a=exnum(input,i);
  return a;
}
int exnum(string input,int &i){
  int a=0;
  while(isdigit(input[i])){
    a*=10;
    a+=input[i]-'0';
    i++;
  }
  
  return a;
}

int main(){
  int n;
  cin>>n;
  repn(k,n){
    int i=0;
    string input;
    cin>>input;
    cout<<ex1(input,i)<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <vector>
using namespace std;
string input;
inline int op(const string op, int a, int b)
{
    if (op == "+")
        return a + b;
    if (op == "-")
        return a - b;
    if (op == "*")
        return a * b;
    if (op == "/")
        return a / b;
}
inline bool is_all_digit(string in)
{
    for (auto i : in)
    {
        if (!isdigit(i))
            return false;
    }
    return true;
}
vector<string> split(string in)
{
    vector<string> spl;
    int pos = 0;
    if (in[pos] == '-')
    {
        pos++;
        while (pos < in.size())
        {
            if (isdigit(in[pos]))
            {
                pos++;
            }
            else
            {
                break;
            }
        }
        spl.push_back(in.substr(0, pos));
        in.erase(0, pos);
        pos = 0;
    }
    while (pos < in.size())
    {
        if (!isdigit(in[pos]))
        {
            if (pos != 0)
            {
                spl.push_back(in.substr(0, pos));
                in.erase(0, pos);
                pos = 0;
            }
            else
            {
                if (in[0] == '(')
                {
                    int cnt = 1;
                    int r_pos = 1;
                    for (r_pos = 1; r_pos < in.size(); r_pos++)
                    {
                        if (in[r_pos] == '(')
                            cnt++;
                        if (in[r_pos] == ')')
                            cnt--;
                        if (cnt == 0)
                            break;
                    }
                    spl.push_back(in.substr(pos + 1, r_pos - 1));
                    in.erase(0, r_pos + 1);
                    pos = 0;
                    continue;
                }
                else if (in[0] == '+' || in[0] == '-' || in[0] == '*' || in[0] == '/')
                {
                    spl.push_back(in.substr(0, 1));
                    in.erase(0, 1);
                    pos = 0;
                }
            }
        }
        else
        {
            pos++;
        }
    }
    if (in.size() != 0)
        spl.push_back(in);
    return spl;
}
int cal(string &in_str)
{
    auto in = split(in_str);
    while (in.size() == 1)
    {
        if ((in[0][0] == '-' && is_all_digit(in[0].substr(1))) || (is_all_digit(in[0])))
            break;
        in = split(in[0]);
    }
    auto pos = in.begin();
    auto lambda = [&]() {pos--;*pos = to_string(op(*(pos+1),cal(*pos), cal(*(pos + 2))));in.erase(pos + 1, pos + 3); };
    while (in.size() != 1)
    {
        while (pos != in.end())
        {
            if (*pos == "*" || *pos == "/")
                lambda();
            if (in.size() == 1)
                break;
            if (pos != in.end())
                pos++;
        }
        pos = in.begin();
        while (pos != in.end())
        {
            if (*pos == "+" || *pos == "-")
                lambda();
            if (in.size() == 1)
                break;
            if (pos != in.end())
                pos++;
        }
    }
    return (stoi(in[0]));
}
int main()
{

    int n;
    cin >> n;
    while (n--)
    {
        cin >> input;
        input.erase(input.end() - 1);
        cout << cal(input) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cctype> // for isdigit
#include <string>
using namespace std;
// ?§?????§£??????????????°????????§?????¢??°???????????????????????£?¨????????????¨
int exp(string s, int &i);
int term(string s, int &i);
int factor(string s, int &i);
int number(string s, int &i);
int exp(string s, int &i)
{
  int val = term(s, i);
  while(s[i] == '+' || s[i] == '-'){ // 0 ?????\?????°?????????????????¨???????????????
    char op = s[i];
    i++;
    int val2 = term(s, i);
    if(op == '+') val += val2;
    else val -= val2;
  }
  return val;
}
int term(string s, int &i)
{
  int val = factor(s, i);
  while(s[i] == '*' || s[i] == '/'){ // 0 ?????\?????°?????????????????¨???????????????
    char op = s[i];
    i++;
    int val2 = factor(s, i);
    if(op == '*') val *= val2;
    else val /= val2;
  }
  return val;
}
int factor(string s, int &i)
{
  // ??????????????????????????°????????´???
  // isdigit ?????¢??????????????\????¬????????????????????????§???????????¨
  if(isdigit(s[i]))
    return number(s, i);
  // ??°?????§???????????´??????????????§?§?????????£???????????°???????????????'(' ??¨??????
  i++; // '(' ??????????£???°???
  int val = exp(s, i);
  i++; // ')' ??????????£???°???
  return val;
}
int number(string s, int &i)
{
  // ??°??????1 ????????¨???
  int n = s[i] - '0';
  i++;
  // ??°??????2 ?????\????????¨???
  while(isdigit(s[i])){
    n = n * 10 + (s[i] - '0');
    i++;
  }
  return n;
}
int main()
{
  int n;
  cin >> n;
  for(int j = 0; j < n; ++j){
    string s;
    cin >> s;
    int i = 0;
    cout << exp(s, i) << endl;
  }
}