AlbertMourato

Interpretador

Dec 1st, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package logica;
  2. import java.util.*;
  3. import java.math.*;
  4. public class Avaliador {
  5.     public static void main(String args[]){
  6.         Scanner in = new Scanner(System.in);
  7.         int v;
  8.         int parentesesE = 0, parentesesD = 0;
  9.         int qtdExpressoes;
  10.         String exp;
  11.        
  12.         int op = in.nextInt();
  13.         String operacao = in.next();
  14.         int linhas = (int)Math.pow(2, op);
  15.         int tabela[][] = new int[linhas][op+1];
  16.         for(int i = 0; i<linhas;i++){
  17.             for(int j = 0; j<op+1; i++){
  18.                 tabela[i][j] = in.nextInt();
  19.             }
  20.         }
  21.         qtdExpressoes = in.nextInt();
  22.         int k = 0;
  23.         while(k<qtdExpressoes){
  24.             exp = in.nextLine();
  25.             v = 0;
  26.             while(v<exp.length()-1){
  27.                 if(exp.substring(v)=="("){
  28.                     parentesesE++;
  29.                 }
  30.                 if(exp.substring(v)==")"){
  31.                     parentesesD++;
  32.                 }
  33.                 v++;
  34.             }
  35.             if(parentesesE!=parentesesD){
  36.                 System.out.println("Expressao mal-formada");
  37.             }
  38.             else if(exp.substring(0)==")"||exp.substring(exp.length()-1)=="("){
  39.                 System.out.println("Expressao mal-formada");
  40.             }
  41.             else{
  42.                
  43.             }
  44.            
  45.             k++;
  46.         }
  47.        
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment