elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


  Mostrar Temas
Páginas: [1]
1  Programación / Java / evaluacion postfija en: 23 Octubre 2013, 23:04 pm
hola a todos se que es algo facil  :-X pero no consigo sacarlo  :-\ espero y me puedan ayudar mi codigo
para evaluar una expresion en postfijo

Código
  1. public static void main(String arg[]){
  2. String expres = "362*4/+";  //Resultado debe ser 6
  3.        System.out.println("Evaluacion de una expresion en posfijo");
  4.        System.out.println("\n Exp posfija:"+expres+"\n");
  5.        //convertir array expresion
  6.        char[]expresiion = expre.toCharArray();
  7.        //Pila de salida y pila de entrada
  8.        char simboloEntrada,op1,op2,valor=0;
  9.        MyFirstStack pilita = new MyFirstStack(expresiion.length);
  10.  
  11.  
  12.  
  13.        for(int a=0;a<expresiion.length;a++){
  14.            simboloEntrada = expre.charAt(a);
  15.            if(simboloEntrada != '+' && simboloEntrada != '-' && simboloEntrada != '*' && simboloEntrada != '/'){
  16.                pilita.push(simboloEntrada);
  17.            }
  18.            else {
  19.  
  20.                op1= pilita.pop();
  21.                op2= pilita.pop();
  22.                valor=(char)evaluate(simboloEntrada,op1,op2);
  23.  
  24.                pilita.push(valor);
  25.            }
  26.        }
  27.  
  28.  
  29.        System.out.print("El valor:"+valor);
  30.  
  31.    }
  32. static int evaluate (char cad, char a, char b ){
  33.  
  34.    int op1=a-48;
  35.    int op2=b-48;
  36.  
  37.    if(cad== '-')
  38.        return op1-op2;
  39.  
  40.    if(cad== '+')
  41.        return op1+op2;
  42.  
  43.    if(cad== '/')
  44.        return op1/op2;
  45.  
  46.    if(cad== '*')
  47.        return op1*op2;
  48.  
  49.  
  50.    return 0;
  51.    }
  52. }

Muchas gracias.
2  Programación / Scripting / Violent Python en: 20 Mayo 2013, 06:17 am
No se si ya este en el foro .
Pero encontre este libro y quise traerlo para ustedes

Violent Python. A Cookbook for Hackers, Forensic Analysts, Penetration Testers and Security Engineers

Chapter 1: Introduction
Chapter 2: Penetration Testing with Python
Chapter 3: Forensic Investigations with Python
Chapter 4: Network Traffic Analysis with Python
Chapter 5: Wireless Mayhem with Python
Chapter 6: Web Recon With Python
Chapter 7: Antivirus Evasion with Python


http://www.mediafire.com/view/?bmpmas43o9ftosa
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines