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>
using namespace std;
// const string S = "(1+1)*2";
string S;
int cur = 0;
int digit();
int number();
int factor();
int term();
int _term(int m);
int exp();
int _exp(int m);
int parse();
bool isdigit(char);
bool is_plu_min(char);
bool is_tim_div(char);
int main() {
  int N;
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> S;
    cur = 0;
    S.resize(S.size()-1);
    cout << parse() << endl;
  }
  return 0;
}
int digit() {
  int n = S[cur] - '0';
  cur++;
  return n;
}
int number() {
  int n = digit();
  while (cur < S.size() && isdigit(S[cur]))
    n = n*10 + digit();
  return n;
}
bool isdigit(char c) {
  if (c <= '9' and c >= '0') return true;
  else return false;
}
bool is_plu_min(char c) {
  if (c == '+' || c == '-') return true;
  else return false;
}
bool is_tim_div(char c) {
  if (c == '*' || c == '/') return true;
  else return false;
}
// exp    = term exp`
// exp`   = + term exp` | eps
// term   = factor term`
// term`  = * factor term` | eps
// factor = ( exp ) | num
int term() {
  int n = factor();
  return _term(n);
}
int _term(int m) {
  int n = m;
  switch (S[cur]) {
    case '*':
      cur++;
      n *= factor();
      return _term(n);
    case '/':
      cur++;
      n /= factor();
      return _term(n);
    default:
      return n;
  }
}
int factor() {
  if (S[cur] != '(') return number();
  else {
    cur++;
    int n = exp();
    if (S[cur] != ')') {printf("%s\n","Error about Paren");return 1000000000;}
    cur++;
    return n;
  }
}
int exp() {
  int n = term();
  return _exp(n);
}
int _exp(int m) {
  int n = m;
  switch (S[cur]) {
    case '+':
      cur++;
      n += term();
      return _exp(n);
    case '-':
      cur++;
      n -= term();
      return _exp(n);
    default:
      return n;
  }
}
int parse() {
  return exp();

C++: 
#include <iostream>
#include <string>
#include <cctype>/////////////////////////////////////
#include <memory>
class Parser{

private:
    
    typedef std::string::const_iterator State;
public:
    Parser(){

    }
    ~Parser(){}

    long long int parse(std::string o_s){
        std::string::const_iterator s=o_s.begin();


        return expression(s);
    }
    long long int num_or_brackets(State &b){
        long long int result=-1;
        if(*b=='('){
            b++;
            result=expression(b);
            if(*b==')'){
                b++;
            }else{
                std::cout << "括弧の対応が正しくありません" << std::endl;
            }
        }else if(isdigit(*b)){
            result=number(b);
        }else if(*b==')'){
            std::cout << "括弧の対応が正しくありません" << std::endl;
        }else{
            std::cout << "数式に数字，記号以外のものが含まれています: "<<*b << std::endl;
            return -1;
        }
        return result;
    }
    long long int number(State &b){
        long long int result = 0;
        while(isdigit(*b)){
            result *= 10;
            result += (long long int)(*b - '0');
            b++;
        }
        return result;
    }
    long long int term(State &b){
        long long int result=num_or_brackets(b);
        while(1){
            if(*b=='*'){
                b++;
                result *= num_or_brackets(b);

            }else if(*b=='/'){
                b++;
                result /= num_or_brackets(b);
            }else{
                break;
            }
        }
        //std::cout << result << std::endl;
        return result;
    }
    long long int expression(State &b){
        long long int result;
        if(*b=='-'){
            result = -term(b);
        }else{
            result = term(b);


        }
        while(*b!='\0'){
            if(*b=='+'){
                b++;
                result += term(b);
            }else if(*b=='-'){
                b++;
                result -= term(b);
            }else if(*b==')'||*b=='='){
                return result;
            }else{
                std::cout << "数式に数字，記号以外のものが含まれています: "<<*b << std::endl;
                return -1;
            }
        }
        return result;
    }



};


int main(){
    std::unique_ptr<Parser> parser(new(Parser));
    long long int n;
    std::cin >> n;
    std::string s;

    for (long long int i=0; i < n; i++)
    {

        std::cin >> s;
        std::cout<<parser->parse(s)<<std::endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<ctype.h>

std::string s;
std::string::iterator it;

int term();
int fact();

// 計算
int expr()
{
 	int p = term();
	
	// + or -
	while( *it == '+' || *it == '-' ){
	 	if( *it == '+' ){
		 	it++;
			int q = term();
			p += q;
		}
		else{
		 	it++;
			int q = term();
			p -= q;
		}
	}
	
	return p;
}

// 項を計算
int term()
{
	int p = fact();
	
	while( *it == '*' || *it == '/' ){
	 	if( *it == '*' ){
		 	it++;
			int q = fact();
			p *= q;
		}
		else{
		 	it++;
			int q = fact();
			p /= q;
		}
	}
	
	return p;
}

// 括弧内 or 数字
int fact()
{
 	if( *it == '(' ){
	 	it++;
		int p = expr();
		it++;
		
		return p;
	}
	else{
	 	int p = 0;
		
		while( isdigit( *it ) ){
			p *= 10;
			p += *it - '0';
			it++;
		}
		
		return p;
	}
}

int main()
{
	int n;
	std::cin >> n;
	
	while( n-- ){
		std::cin >> s;
		s[s.size()-1] = '\0';
		it = s.begin();
		std::cout << expr() << std::endl;
	}

 	return 0;
}