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>
#include<cstdio>

using namespace std;

char siki[200];
int cur;


int digit(){
  int n=siki[cur]-'0';
  ++cur;
  return n;
}

int number(){
  int n=digit();
  while(cur<strlen(siki) && isdigit(siki[cur]))
    n=n*10+digit();

  return n;
}

int factor();

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

int expression(){
  int a=term();
  while(cur<strlen(siki) && (siki[cur]=='+' || siki[cur]=='-')){
    char op=siki[cur];
    cur++;
    int b=term();
    if(op=='+')a+=b;else a-=b;
  }
  return a;
}

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

int main(){
  int n;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>siki;
    cur=0;
    cout<<expression()<<endl;
  }
}

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

int cal1();
int cal2();
int cal3();

int index;
string s;

int getNum(){
	int n = 0;
	for (; '0' <= s[index] && s[index] <= '9'; index++) n = n * 10 + s[index] - '0';
	return n;
}

int cal1(){
	int ret = cal2();
	while (1){
		if (s[index] == '+') {
			index++;
			ret += cal2();
		}
		else if (s[index] == '-') {
			index++;
			ret -= cal2();
		}
		else return ret;
	}
}

int cal2(){
	int ret = cal3();
	while (1){
		if (s[index] == '*') {
			index++;
			ret *= cal3();
		}
		else if (s[index] == '/') {
			index++;
			ret /= cal3();
		}
		else return ret;
	}
}

int cal3(){
	int ret = 0;
	int old = index;
	if (s[index] == '('){
		index++;
		ret = cal1();
		index++;
	}
	else {
		ret = getNum();
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	getchar();
	for (int i = 0; i < n; i++){
		index = 0;
		getline(cin, s);
		s.pop_back();
		cout << cal1() << endl;
	}
	return 0;
}

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

int op_priority(char a) {
	if(a == '+' || a == '-')
		return 0;
	if(a == '*' || a == '/')
		return 1;
	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);
		}
	}

	if(op_stack.size() != 1)
		exit(1);

	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;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int n,tmp,op1,work;
	char line[101],calc;
	stack<int> NUM,work_num;
	stack<char> OP,work_op;

	bool numFLG;

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s",line);

		tmp = 0;
		numFLG = false;

		for(int k = 0; line[k] != '\0'; k++){
			if(line[k] >= '0' && line[k] <= '9'){
				numFLG = true;
				tmp = 10*tmp + (line[k] - '0');
			}else{

				if(numFLG == true){

					if(OP.empty() == false && (OP.top() == '*' || OP.top() == '/')){
						calc = OP.top();
						OP.pop();
						op1 = NUM.top();
						NUM.pop();

						if(calc == '*'){
							NUM.push(tmp*op1);
						}else{
							NUM.push(op1/tmp);
						}
					}else{
						NUM.push(tmp);
					}

					numFLG = false;
					tmp = 0;
				}


				if(line[k] == '+' || line[k] == '-' || line[k] == '*' || line[k] == '/' || line[k] == '('){
					OP.push(line[k]);
				}else if(line[k] == ')'){

					work = NUM.top();
					NUM.pop();
					work_num.push(work);

					while(true){
						calc = OP.top();
						OP.pop();
						if(calc == '(')break;

						work_op.push(calc);

						work = NUM.top();
						NUM.pop();
						work_num.push(work);
					}

					work = work_num.top();
					work_num.pop();

					while(!work_num.empty()){
						calc = work_op.top();
						work_op.pop();

						if(calc == '+'){
							work += work_num.top();
						}else if(calc == '-'){
							work -= work_num.top();
						}else if(calc == '*'){
							work *= work_num.top();
						}else{
							work /= work_num.top();
						}
						work_num.pop();
					}

					NUM.push(work);

				}else{
					work = NUM.top();
					NUM.pop();
					work_num.push(work);

					while(!NUM.empty()){
						calc = OP.top();
						OP.pop();

						work_op.push(calc);

						work = NUM.top();
						NUM.pop();
						work_num.push(work);
					}

					work = work_num.top();
					work_num.pop();

					while(!work_num.empty()){
						calc = work_op.top();
						work_op.pop();

						if(calc == '+'){
							work += work_num.top();
						}else if(calc == '-'){
							work -= work_num.top();
						}else if(calc == '*'){
							work *= work_num.top();
						}else{
							work /= work_num.top();
						}
						work_num.pop();
					}

					printf("%d\n",work);
				}
			}
		}

	}


	return 0;
}

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

int calc2(char *eq){
	int c=0,num[100]={0}, sign[100]={0};
	char *p = eq;
	while(*p){
		if('0'<=*p && *p<='9') num[c]=num[c]*10+*p-'0';
		else{
			if(*p=='+') sign[c]=1;
			else if(*p=='-') sign[c]=2;
			else if(*p=='*') sign[c]=3;
			else if(*p=='/') sign[c]=4;
			else if(*p=='=') break;
			else printf("err %c\n", *p);
			c++;
		}
		p++;
	}
	c++;
	for(int i=0;i<c;i++){
		if(sign[i]==3 || sign[i]==4){
			if(sign[i]==3)	num[i+1] = num[i] * num[i+1];
			if(sign[i]==4)	num[i+1] = num[i] / num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	for(int i=0;i<c;i++){
		if(sign[i]==1 || sign[i]==2){
			if(sign[i]==1)	num[i+1] = num[i] + num[i+1];
			if(sign[i]==2)	num[i+1] = num[i] - num[i+1];
			for(int j=i+1;j<c;j++){
				num[j-1] = num[j];
				sign[j-1] = sign[j];
			}
			i--;
			c--;
		}
	}
	return num[0];
}

int calc(char *eq){
	char *p, *p2, buf[120]={0}, cp[120]={0};
	int k,ret;
	strcpy(cp, eq);
	if((p=strchr(cp, '('))!=NULL){
		for(k=0,p2=p+1;;p2++)
			if(*p2=='(')k++;
			else if(*p2==')'){
				if(k)k--;
				else break;
			}
		memcpy(buf, p+1, p2-p-1);
		buf[p2-p-1]='=';
		ret = calc(buf);
		*p=0;
		sprintf(buf, "%s%d%s", cp, ret, p2+1);
		strcpy(cp,buf);
	}
	return calc2(cp);
}

int main(){
	int i,j,n;
	char buf[120], p;
	for(cin >> n;n;n--){
		cin >> buf;
		cout << calc(buf) <<endl;
	}
	return 0;
}