Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. void Comparar(no *l1, no *l2)
  2. {
  3. while (l1->prox!= NULL){
  4. l1= l1;
  5. while(l2->prox!= NULL){
  6. l2= l2;
  7. if(l1->info == l2->info){
  8.  
  9. printf("Iguaisnn");
  10. } else
  11. printf("Diferentesnn");
  12. system("pause");
  13. }
  14.  
  15. }
  16.  
  17. }
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. typedef struct no {
  22. int info;
  23. struct no* prox;
  24. }no;
  25.  
  26.  
  27.  
  28. no* cria_no (void) {
  29. return NULL;
  30. }
  31.  
  32.  
  33.  
  34. no* inserir (no* lst, int v) {
  35. no* novo = (no*) malloc(sizeof(no));
  36. novo->info = v;
  37. novo->prox = lst;
  38. return novo;
  39. }
  40.  
  41.  
  42. void Comparar(no *l1, no *l2)
  43. {
  44. while (l1->prox!= NULL){
  45. l1= l1;
  46. while(l2->prox!= NULL){
  47. l2= l2;
  48. if(l1->info == l2->info){
  49.  
  50. printf("Iguaisnn");
  51. } else
  52. printf("Diferentesnn");
  53. system("pause");
  54. }
  55.  
  56. }
  57.  
  58. }
  59. int main (void)
  60. {
  61. no* lst1;
  62. no* lst2;
  63.  
  64. lst1 = cria_no();
  65. lst1 = inserir(lst1, 21);
  66. lst1 = inserir(lst1, 45);
  67. lst1 = inserir(lst1, 10);
  68.  
  69. lst2 = cria_no();
  70. lst2 = inserir(lst2, 21);
  71. lst2 = inserir(lst2, 45);
  72. lst2 = inserir(lst2, 5);
  73.  
  74.  
  75. printf("nAS LISTAS SAO:n");
  76.  
  77. Comparar(lst1,lst2);
  78.  
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement