Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include <stdlib.h>
- main ()
- {
- int arreglo[100];
- int opcion; /*** guarda el numero ha elejir del menu **/
- int tope=0;
- int contadorMOSTRAR; /** contador del for de mostrar las pilas **/
- int cantidad; /** guarda la cantidad de elementos que quiero agregar **/
- int cantidadELIMINAR; /** guarda la cantidad de elementos que quiero eliminar **/
- do
- {
- system("cls");
- printf("\n\tPOR FAVOR ELIJA UNA DE LAS SIGUIENTES OPCIONES\n\n\n\n");
- printf("\t\t\tPILA\n");
- printf("\n\t1.INGRESAR UN DATO A LA PILA \n\n");
- printf("\t2.MOSTRAR DATOS DE LA PILA\n\n");
- printf("\t3.ELIMINAR DATO DE LA PILA \n\n");
- printf("\t4.SALIR DEL PROGRAMA \n");
- scanf("%i",&opcion);
- switch(opcion) {
- /****** FUNCION DE AGREGAR ELEMENTO A LA PILA*********/
- case 1:{
- system ("cls");
- printf("\t INTRODIZCA EL DATO DE LA PILA NUMERO : ");
- scanf("%i",&arreglo[tope++]);
- }break;
- /************ FUNCION QUE MUESTRA LAS PILA **************/
- case 2:{
- /** COMPARA SI ESTA VACIA **/
- system("cls");
- if ( tope==0 )
- {
- printf("\t LA PILA ESTA VACIA\n");
- }
- else
- {
- printf("\tDATOS DE LA PILA\n\n");
- for(contadorMOSTRAR=0; contadorMOSTRAR<tope; contadorMOSTRAR++)
- {
- printf("\n\t%d ",arreglo[contadorMOSTRAR]);
- }
- }
- }
- getch();
- break;
- /******** FUNCION DE ELIMINA *************/
- case 3:
- {
- system ("cls");
- if (tope==0)
- {
- printf("\n\t\t NO HAY PILA QUE RETIRAR");
- getch();
- }
- else
- {
- tope--;
- printf("el elemento fue eliminado \n");
- getch();
- }
- }
- break;
- /*******************************************/
- /*******************************************/
- /******** SALE DEL PROGRMA ***********/
- /*******************************************/
- /*******************************************/
- case 4:
- {
- printf("\tSALIENDO...\n");
- return 0;
- }
- break;
- }
- }
- while(opcion!=5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement