Advertisement
attackers

williamsD

Nov 23rd, 2011
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include <stdlib.h>
  4.  
  5. main ()
  6.  
  7. {
  8.  
  9.     int arreglo[100];
  10.     int opcion;  /*** guarda el numero ha elejir del menu **/
  11.     int tope=0;
  12.  
  13. int contadorMOSTRAR;  /** contador del for de mostrar las  pilas **/
  14. int cantidad;  /** guarda la cantidad de elementos que quiero agregar **/
  15. int cantidadELIMINAR; /** guarda la cantidad de elementos que quiero eliminar **/
  16.  
  17. do
  18. {
  19. system("cls");
  20. printf("\n\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES\n\n\n\n");
  21. printf("\t\t\tPILA\n");
  22. printf("\n\t1.INGRESAR UN DATO A LA PILA \n\n");
  23. printf("\t2.MOSTRAR DATOS DE LA PILA\n\n");
  24. printf("\t3.ELIMINAR DATO DE LA PILA \n\n");
  25. printf("\t4.SALIR DEL PROGRAMA \n");
  26.  
  27. scanf("%i",&opcion);
  28. switch(opcion)   {
  29.  
  30. /****** FUNCION DE AGREGAR ELEMENTO A LA PILA*********/
  31. case 1:{
  32. system ("cls");
  33.  
  34. printf("\t INTRODIZCA EL DATO DE LA PILA NUMERO : ");
  35. scanf("%i",&arreglo[tope++]);
  36.  
  37.  
  38.  
  39. }break;
  40.  
  41.  
  42.  
  43. /************ FUNCION QUE MUESTRA LAS PILA **************/
  44. case 2:{
  45.      
  46.        /** COMPARA SI ESTA VACIA **/
  47.        system("cls");
  48.      if ( tope==0 )
  49.      {
  50.      printf("\t LA PILA ESTA VACIA\n");
  51.      }
  52.                 else
  53.                  {
  54.      printf("\tDATOS DE LA PILA\n\n");
  55.                 for(contadorMOSTRAR=0; contadorMOSTRAR<tope; contadorMOSTRAR++)
  56.                 {
  57.                 printf("\n\t%d ",arreglo[contadorMOSTRAR]);
  58.                 }
  59.                 }
  60.                 }
  61. getch();
  62. break;
  63.  
  64.  
  65.  
  66.  
  67. /********   FUNCION DE ELIMINA *************/
  68. case 3:
  69.      {
  70. system ("cls");
  71.                   if (tope==0)
  72.                           {
  73.                           printf("\n\t\t NO HAY PILA QUE RETIRAR");
  74. getch();
  75.                           }
  76.                           else
  77.                           {
  78.                
  79.                           tope--;
  80.                     printf("el elemento fue eliminado \n");
  81.                
  82. getch();
  83.                
  84.                 }
  85.                 }
  86. break;
  87.  
  88.  
  89.  
  90. /*******************************************/
  91. /*******************************************/
  92. /********   SALE DEL PROGRMA   ***********/
  93. /*******************************************/
  94. /*******************************************/
  95. case 4:
  96. {
  97.  
  98. printf("\tSALIENDO...\n");
  99.  
  100. return 0;
  101.  
  102. }
  103.  
  104. break;
  105. }
  106. }
  107.  
  108. while(opcion!=5);
  109.  
  110. }
  111.  
  112.  
  113.  
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement