Advertisement
pablosotol

Ejercicio Datos

Sep 29th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<stdint.h>
  4.  
  5. struct s_nodo{
  6. uint8_t key;
  7. struct s_nodo* vinculo1;
  8. struct s_nodo* vinculo2;
  9. struct s_nodo* vinculo3;
  10. };
  11.  
  12. typedef struct s_nodo nodo_t;
  13. typedef struct s_nodo* pnodo_t;
  14.  
  15. pnodo_t crea_nodo(uint8_t key){
  16. pnodo_t p;
  17. p=malloc(sizeof(nodo_t));
  18. if(p==NULL){
  19. perror("Error en crea_nodo()\n");
  20. exit(EXIT_FAILURE);
  21. }
  22. p->key=key;
  23. p->vinculo1=NULL;
  24. p->vinculo2=NULL;
  25. p->vinculo3=NULL;
  26.  
  27. return (p);
  28. }
  29.  
  30. int main(){
  31. pnodo_t inicio;
  32. inicio=crea_nodo('B');
  33.  
  34. inicio->vinculo1=crea_nodo('A');
  35.  
  36. inicio->vinculo1->vinculo1=inicio->vinculo1;
  37. inicio->vinculo2=inicio;
  38. inicio->vinculo3=inicio;
  39.  
  40. inicio->vinculo1->vinculo2=inicio;
  41. inicio->vinculo1->vinculo3=inicio;
  42.  
  43. printf("inicio->vinculo2=inicio: %c\n", inicio->vinculo2->key);
  44. printf("inicio->vinculo1=nodoA: %c\n", inicio->vinculo1->key);
  45. return(EXIT_SUCCESS);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement