You are on page 1of 1

Insertar Dato en un lista por el final - Foros del Web

1 de 1

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.

http://www.forosdelweb.com/f96/insertar-dato-lista-por-final-809763/#

struct nodo
{
int numero;
struct nodo*sig;
};
struct nodo *CrearLista()
{
struct nodo *p;
p = (struct nodo*) malloc(sizeof(struct nodo));
return p;
}
void InsertarFinal(struct nodo **lista)
{
struct nodo *aux,*aux2;
int n,i=0;
aux=CrearLista();
aux2=*lista;
printf("Introduce un numero\n");
scanf("%d",&n);
if(aux!=NULL)
{
if(aux2==NULL)
{
aux -> numero=n;
aux ->sig=*lista;
*lista=aux;
}
else
{
aux -> numero=n;
while(aux2->sig!=NULL)
{
aux2=aux2->sig;
aux2->sig=aux;
aux->sig=NULL;

09/10/2013 08:02 p.m.

You might also like