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 <bits/stdc++.h>

using namespace std;

long long int calc(string ex){
	long long int str,cnt,ans=0,now=0,addn=1,addd=1,n=ex.length(),i;
	bool sus=false,minus=false;
	char pm='+',md='*';
	for(i=0; i<n; i++){
		if(sus){
			if(ex[i]=='('){
				cnt++;
			}else if(ex[i]==')'){
				cnt--;
				if(cnt == 0){
					now = calc(ex.substr(str,i-str));
					sus = false;
				}
			}
		}else{
			switch(ex[i]){
				case '(':
					str = i+1;
					cnt = 1;
					sus = true;
					break;
				case '-':
					if(i==0 || ex[i-1]== '+' || ex[i-1]== '-' || ex[i-1]== '*' || ex[i-1]== '/'){
						minus = true;
						break;
					}
				case '+':
					if(minus){
						now *= -1;
						minus = false;
					}
					if(md == '*'){
						addn *= now;
					}else{
						addd *= now;
					}
					if(pm == '+'){
						ans += addn/addd;
					}else{
						ans -= addn/addd;
					}
					pm = ex[i];
					md = '*';
					now = 0;
					addn = 1;
					addd = 1;
					break;
				case '*':
				case '/':
					if(minus){
						now *= -1;
						minus = false;
					}
					if(md == '*'){
						addn *= now;
					}else{
						addd *= now;
					}
					md = ex[i];
					now = 0;
					break;
				case '0':
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9':
					now *= 10;
					now += ex[i]-'0';
					break;
				default:
					break;
			}
		}
	}
	if(minus){
		now *= -1;
		minus = false;
	}
	if(md == '*'){
		addn *= now;
	}else{
		addd *= now;
	}
	if(pm == '+'){
		ans += addn/addd;
	}else{
		ans -= addn/addd;
	}
	return ans;
}

int main(void){
	int n,i;
	long long int ans;
	string str;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> str;
		ans = calc(str);
		cout << ans << endl;
	}
	return 0;
}

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

int hyoka(string);
int isNum(int);

int main(){
	int n,i;
	string s;
	
	cin>>n;
	for(i=0;i<n;i++){
	 cin>>s;
	 cout<<hyoka(s)<<endl;
	}
		
	return 0;
}


int hyoka(string s){
	long int total=0,work=0;
	long int tmp1,tmp2;
	int oi=0;
	char oc;
	int n;
	string cs;
	
	if(isNum(s[oi])!=-1){s="+"+s;}
	
	while(1){
	 oc=s[oi];if(oc=='='){total+=work;break;}
	 
	 if(s[oi+1]!='('){	//??°???????????????
	  tmp1=0;
	  while(1){
	   oi++;
	   tmp2=s[oi];
	   if(tmp2!=-1){tmp1=tmp1*10+tmp2;}else{break;}
	  }
	 }else{	//??????????????°
	  cs="";n=1;oi++;
	  while(1){
	   oi++;
	   switch(s[oi]){
		case '(':n++;break;
		case ')':n--;break;
	   }
	   if(n!=0){cs+=s[oi];}else{break;}
	  }
	  cs+='=';
	  tmp1=hyoka(cs);
	 }
	
	 switch(oc){
	  case '+':total+=work;work=tmp1;break;
	  case '-':total+=work;work=-tmp1;break;
	  case '*':work*=tmp1;break;
	  case '/':work/=tmp1;break;
	 }
	}
	
	return total;
}

int isNum(int c){
	if(49<=c && c<=57){
	 return c-49;
	}
	return -1;
}

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();
    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<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>

#include<cassert>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

string S;
int cur = 0;//?§£???????§???????

int expression();//????????£?¨?

int digit(){
	// assert(isdigit(S[cur]));
	// cout<<"S[cur]="<<S[cur]<<endl;;
	int n = S[cur++] - '0';
	return n;
}

int number(){
	int n = digit();
	while(cur<S.size() && isdigit(S[cur]))n = n*10+digit();
	return n;
}

int factor(){
	if(S[cur]!='(')return number();
	cur++;
	int n=expression();
	// assert(S[cur++]==')');
	return n;
}

int term(){
	int a = factor();
	while(cur<S.size() && (S[cur]=='*' || S[cur]=='/')){
		char op = S[cur++];
		int b = factor();
		if(op=='*')a*=b;else a/=b;
	}
	return a;
}

int expression() {
	int a = term();
	while (cur<S.size() && (S[cur] == '+' || S[cur] == '-')) { // ?¶???????????????????????¶???????
		char op = S[cur++];
		int b = term();
		if (op == '+')a+=b;else a-=b;
	}
	return a;
}

int main(){
	int N;
	int ans[50];
	cin>>N;
	rep(i,N){
		cur=0;
		cin>>S;
		S.resize(S.size()-1);
		ans[i]=expression();
	}
	rep(i,N)cout<<ans[i]<<endl;
	return 0;
}

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

int op_priority(char a) {
	if(a == '+' || a == '-')
		return 0;
	if(a == '*')
		return 1;
	if(a == '/')
		return 2;
	return -1;
}

void clac_once(stack<long long> & num_stack, stack<char> & op_stack) {
	long long a, b;
	long long c;
	char op;

	b = num_stack.top();
	num_stack.pop();
	a = num_stack.top();
	num_stack.pop();
	op = op_stack.top();
	op_stack.pop();

	switch(op) {
		case '+' :
			c = a + b;
			break;
		case '-':
			c = a - b;
			break;
		case '*':
			c = a * b;
			break;
		case '/':
			c = a / b;
	}

	num_stack.push(c);
}

long long clac(string str) {
	stack<long long> num_stack;
	stack<char> op_stack;

	for(int i = 0; i < str.size();) {
		if(str[i] == '(') {
			int start = ++i;
			int count = 1;

			while(count) {
				if(str[i] == ')')
					count--;
				else if(str[i] == '(')
					count++;
				i++;
			}

			num_stack.push(clac(string(str.begin() + start, str.begin() + i)));
		}
		else if(str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/' || str[i] == '=' || str[i] == ')') {
			while(!op_stack.empty() && op_priority(op_stack.top()) >= op_priority(str[i])) {
				clac_once(num_stack, op_stack);
			}
			op_stack.push(str[i]);
			i++;
		}
		else if('0' <= str[i] && str[i] <= '9') {
			long long tmp = 0;
			while('0' <= str[i] && str[i] <= '9') {
				tmp *= 10;
				tmp += str[i] - '0';
				i++;
			}
			num_stack.push(tmp);
		}
	}

	return num_stack.top();
}

int main() {
	int n;

	cin >> n;
	for(int i = 0; i < n; i++) {
		string str;

		cin >> str;
		cout << clac(str) << endl;
	}

	return 0;
}