Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6. typedef struct nodo{
  7.  
  8. int valor;
  9. struct nodo *next;
  10.  
  11. }*Nodo;
  12.  
  13. int esContenido(Nodo listaA, Nodo listaB);
  14.  
  15.  
  16.  
  17. int main(){
  18.  
  19. Nodo listaA=(Nodo)malloc(sizeof(struct nodo));
  20. listaA->valor=5;
  21. listaA->next=NULL;
  22.  
  23. Nodo b=(Nodo)malloc(sizeof(struct nodo));
  24. b->valor=1;
  25. b->next=NULL;
  26.  
  27. Nodo c=(Nodo)malloc(sizeof(struct nodo));
  28. c->valor=3;
  29. c->next=NULL;
  30.  
  31. Nodo d=(Nodo)malloc(sizeof(struct nodo));
  32. d->valor=6;
  33. d->next=NULL;
  34.  
  35. Nodo e=(Nodo)malloc(sizeof(struct nodo));
  36. e->valor=4;
  37. e->next=NULL;
  38.  
  39.  
  40. printf("\n");
  41. listaA->next=b;
  42. b->next=c;
  43. c->next=d;
  44. d->next=e;
  45. e->next=NULL;
  46.  
  47. printf("Lista A:");
  48.  
  49. while(listaA!=NULL){
  50. printf("[%d]->", listaA->valor);
  51. listaA=listaA->next;
  52. }
  53.  
  54. Nodo listaB=(Nodo)malloc(sizeof(struct nodo));
  55. listaB->valor=6;
  56. listaB->next=NULL;
  57.  
  58. Nodo v=(Nodo)malloc(sizeof(struct nodo));
  59. v->valor=4;
  60. v->next=NULL;
  61.  
  62. Nodo x=(Nodo)malloc(sizeof(struct nodo));
  63. x->valor=3;
  64. x->next=NULL;
  65.  
  66. listaB->next=v;
  67. v->next=x;
  68. x->next=NULL;
  69. printf("\nLista B:");
  70.  
  71. while(listaB!=NULL){
  72. printf("[%d]->", listaB->valor);
  73. listaB=listaB->next;
  74. }
  75.  
  76. esContenido(listaA,listaB);
  77. }
  78.  
  79. int esContenido(Nodo listaA, Nodo listaB){
  80.  
  81.  
  82.  
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement