![]() |
funcion crea nodo #include<stdio.h> #include<stdlib.h> #include<conio.h> void main() { int z; struct nodo { int x; struct nodo *siguente; }; struct nodo *p,*q,*L=NULL; while(1) { printf("ingrese valor para lista"); scanf("%d",&z); if(z==0)break; p=L; L=malloc(sizeof(struct nodo)); L->x=z; L->siguente=p; } p=L; while(p != NULL) { printf("%d->",q->x); p=p->siguente; } getch();} no me funciona la funcion para crear el nodo agredeseria alguna ayudita porfa #include<stdio.h> #include<stdlib.h> #include<conio.h> typedef struct node { int x; struct nodo *siguente; }nodo; typedef nodo *L; typedef nodo *pnodo; void crea_nodo(L *l,int y){ pnodo nuevo; nuevo=(pnodo)malloc(sizeof(nodo)); nuevo->x=y; if(l==NULL){ nuevo->siguente=*l; *l=nuevo;} else{ nuevo->siguente=*l; *l=nuevo;} } void main() { L *l; int z; struct nodo { struct nodo *siguente; }; struct nodo *p,*L=NULL; while(1) { printf("ingrese valor para lista"); scanf("%d",&z); if(z==0)break; crea_nodo(&l,z); } getch();} |
Re: funcion crea nodo Te pondre un ejemplo corto y sencillo para que entiendas el funcionamento: Código: #include <stdio.h> |
Re: funcion crea nodo no entiendo muy bn tu codigo |
Re: funcion crea nodo Código: nuevo->siguente=*l; |
| La zona horaria es GMT -6. Ahora son las 19:43. |
Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.