Ver Mensaje Individual
  #4 (permalink)  
Antiguo 02/08/2007, 19:40
Avatar de Nigthmare
Nigthmare
 
Fecha de Ingreso: diciembre-2006
Ubicación: /home/vsanchez
Mensajes: 38
Antigüedad: 17 años, 5 meses
Puntos: 0
Re: Listas, Nesesito Ayuda Con Este Codigo

Mira observe un error en al momento de estar moviendo los punteros cuando agregas un registro, ya sea el primero o no.

Mira este ejemplo:

struct example{
int valor;
example *sig;
}*New,*First=NULL,*Last=NULL;

void agregar(){
New=new example;
cin>>New->valor;
if(First==NULL&&Last==NULL)
First=Last=New;
else
{
Last->sig=New;
Last=New;
}
}

void mostrar()
{
example Current=First;
if(!First)
cout<<"Lista Vacia";
else
{
do{
cout<<Current->valor;
Current=Current->sig;
}while(Current!=Last);
}
}

Espero te sirva este ejemplo, alguna duda sigue posteando en este foro