Advertisement
gmmmarcos

Practico Pilas 1 - ejercicio 9

Apr 1st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "pila.h"
  4.  
  5.  
  6.  
  7. int main()
  8. {
  9.  
  10. int OP=0;
  11. Pila A;
  12. Pila B;
  13. Pila PACK;
  14. inicpila (&A);
  15. inicpila (&B);
  16. inicpila (&PACK);
  17.  
  18. while (OP!=1)
  19. {
  20. printf ("\n Ingrese elemento en PILA A\n");
  21. leer (&A);
  22. printf ("Desea continuar?\n 1. NO\n 2. SI\n");
  23. scanf ("%i",&OP);
  24.  
  25. }
  26. OP=0;
  27. while (OP!=1)
  28. {
  29. printf ("\n Ingrese elemento en PILA B\n");
  30. leer (&B);
  31. printf ("Desea continuar?\n 1. NO\n 2. SI\n");
  32. scanf ("%i",&OP);
  33. }
  34.  
  35.  
  36. while (! pilavacia(&A)&& !pilavacia (&B))
  37. {
  38. apilar (&PACK, desapilar (&A));
  39. apilar (&PACK, desapilar (&B));
  40.  
  41. }
  42.  
  43. if (pilavacia (&A) && pilavacia (&B) )
  44. {
  45. printf("\n TIENEN LA MISMA CANTIDAD DE ELEMENTOS");
  46. }
  47. else
  48. {
  49. if (!pilavacia (&A) && pilavacia (&B))
  50. {
  51. printf ("\n TIENE MAS ELEMENTOS PILA A QUE PILA B");
  52. }
  53. else
  54. {
  55. printf ("\n TIENE MAS ELEMENTOS PILA B QUE PILA A");
  56. }
  57. }
  58.  
  59.  
  60. return 0;
  61. }
  62.  
  63.  
  64.  
  65. /*Comparar la cantidad de elementos de las pilas A y B. Mostrar por pantalla el resultado */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement