Advertisement
gmmmarcos

practico pilas 1 ejercicio 12 (no funciona)

Apr 1st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "pila.h"
  4.  
  5. int main()
  6. {
  7. char OP = 'S';
  8. char PO = 'A';
  9. Pila MODELO;
  10. Pila DADA;
  11. Pila BASURA;
  12. Pila MOMENTO;
  13. inicpila(&BASURA);
  14. inicpila(&MOMENTO);
  15. inicpila (&MODELO);
  16. inicpila (&DADA);
  17.  
  18. while (OP == 'S')
  19. {
  20. printf ("INGRESE EN PILA MODELO\n");
  21. leer (&MODELO);
  22. printf ("DESEA CONTINUAR S = SI / N= NO \n");
  23. fflush(stdin);
  24. scanf ("%c",&OP);
  25. }
  26.  
  27. while (PO == 'A');
  28. {
  29. printf ("Que numero desea apilar en DADA\n");
  30. leer (&DADA);
  31. printf ("DESEA CONTINUAR A = SI / B= NO \n");
  32. fflush(stdin);
  33. scanf ("%c",&PO);
  34. }
  35.  
  36. while (!pilavacia(&MODELO))
  37. {
  38. if (tope (&MODELO) == tope (&DADA))
  39. {
  40. apilar (&BASURA, desapilar (&DADA));
  41. }
  42. else
  43. {
  44. apilar (&MOMENTO, desapilar(&MODELO));
  45. }
  46. }
  47.  
  48. while (!pilavacia(&MOMENTO))
  49. {
  50. apilar (&MODELO, desapilar (&MOMENTO));
  51. }
  52.  
  53.  
  54.  
  55. printf ("PILA DADA\n");
  56. mostrar (&DADA);
  57. printf ("PILA MODELO\n");
  58. mostrar (&MODELO);
  59. printf ("PILA BASURA\n");
  60. mostrar (&BASURA);
  61.  
  62.  
  63.  
  64.  
  65. return 0;
  66. }
  67.  
  68.  
  69.  
  70. /*Suponiendo la existencia de una pila MODELO (vacía o no),
  71. eliminar de la pila DADA todos los elementos que existan en MODELO */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement