Guest User

Untitled

a guest
May 27th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. struct nodo2
  2. {
  3. int datos;
  4. struct nodo2 *siguiente;
  5. };
  6.  
  7. struct nodo2 *agregar(struct nodo2 *cola, int valor);
  8. struct nodo2 *ver(struct nodo2 *mostrar);
  9.  
  10. struct nodo2 *agregar(struct nodo2 *cola, int valor)
  11. {
  12. struct nodo2 *temporal = calloc(sizeof(struct nodo2), 1);
  13. struct nodo2 *pivote;
  14.  
  15. temporal -> datos = valor;
  16.  
  17. if(cola != NULL)
  18. {
  19. pivote = cola;
  20.  
  21. while(pivote -> siguiente != NULL)
  22. {
  23. pivote = pivote -> siguiente;
  24. }
  25. pivote -> siguiente = temporal;
  26.  
  27. return cola;
  28. }
  29. else
  30. {
  31. printf("n Valor: %i", temporal -> datos);
  32. return temporal;
  33. }
  34. }
  35.  
  36. struct nodo2 *ver(struct nodo2 *mostrar)
  37. {
  38. if(mostrar == NULL)
  39. printf("n La cola esta vacia ");
  40. else
  41. {
  42. printf("n Los elementos de la cola son: n");
  43. while(mostrar != NULL)
  44. {
  45. printf("%i-->", mostrar -> datos);
  46. mostrar = mostrar -> siguiente;
  47. }
  48. printf("NULL nn");
  49. }
  50. }
Add Comment
Please, Sign In to add comment