Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct nodo2
- {
- int datos;
- struct nodo2 *siguiente;
- };
- struct nodo2 *agregar(struct nodo2 *cola, int valor);
- struct nodo2 *ver(struct nodo2 *mostrar);
- struct nodo2 *agregar(struct nodo2 *cola, int valor)
- {
- struct nodo2 *temporal = calloc(sizeof(struct nodo2), 1);
- struct nodo2 *pivote;
- temporal -> datos = valor;
- if(cola != NULL)
- {
- pivote = cola;
- while(pivote -> siguiente != NULL)
- {
- pivote = pivote -> siguiente;
- }
- pivote -> siguiente = temporal;
- return cola;
- }
- else
- {
- printf("n Valor: %i", temporal -> datos);
- return temporal;
- }
- }
- struct nodo2 *ver(struct nodo2 *mostrar)
- {
- if(mostrar == NULL)
- printf("n La cola esta vacia ");
- else
- {
- printf("n Los elementos de la cola son: n");
- while(mostrar != NULL)
- {
- printf("%i-->", mostrar -> datos);
- mostrar = mostrar -> siguiente;
- }
- printf("NULL nn");
- }
- }
Add Comment
Please, Sign In to add comment