• Like
Cola memoria dinamica
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Cola memoria dinamica

  • 1,096 views
Published

Cola memoria dinamica

Cola memoria dinamica

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,096
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
9
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. PROGRAMA EN JAVA DONDE SE GUARDAN LOS CARACTERES DE UNAPALABRA EN UNA COLA CON MEMORIA DINAMICAClase Nodopublic class Nodo { char letra; Nodo despues; public Nodo() { }}En la Main.javaimport java.util.Scanner;public class Main { public Main() { } public static void main(String[] args) { // TODO code application logic here Nodo primero=null; Nodo ultimo=null; Nodo aux1 = null; String palabra; Scanner teclado = new Scanner(System.in); System.out.println("palabra "); palabra = teclado.nextLine(); for (int i=0;i<palabra.length();i++) { aux1 = ultimo; Nodo aux = new Nodo(); aux.despues = null; if (primero==null) { primero=aux; ultimo=aux; } else { aux1.despues = aux; ultimo = aux; } ultimo.letra=palabra.charAt(i); } aux1= primero; for (int j=0;j<palabra.length();j++) { System.out.println("letra " + aux1.letra); aux1 = aux1.despues; }
  • 2. }}