procesamiento de datos
TRANSCRIPT
PROCESAMIENTO DE DATOS
PILAS
Clase Principal
package pilas;
import java.util.Scanner;
public class Pilas {
public static void main(String[] args) {
Scanner teclado=new Scanner(System.in);
Nodo tope=null, aux;
char resp;
System.out.println("continuar s/n");
resp=teclado.next().charAt(0);
while (resp=='s'){
aux=new Nodo();
if (tope==null)
aux.antes=null;
else
aux.antes=tope;
teclado.nextLine();
System.out.println("nombre");
aux.nombre=teclado.nextLine();
System.out.println("posicion");
aux.posicion=teclado.nextInt();
tope=aux;
System.out.println("continuar s/n");
resp=teclado.next().charAt(0);
}
while (tope!=null) {
System.out.println("nombre " + tope.nombre + " esta en la posicion
" + tope.posicion);
tope=tope.antes;}
}
}
Clase Nodo
package pilas;
public class Nodo {
protected String nombre;
protected int posicion;
protected Nodo antes; }