Escolar Documentos
Profissional Documentos
Cultura Documentos
Declara varias funciones usadas llamando la consola del sistema operativo las
#include<conio.h> rutinas de I/O. CLRSCR
dato pila[10];
dato pilaaux[10];
int tope=0; ENTERO
int topeaux=0; ENTERO
char op; CARCTER
int ed,cod,x; ENTERO
char nom[30]; CARCTER
char cadena[10]; CARCTER
int *top; ENTERO
PRIMERA FUNCION ADICIONAR UN DATO EN LA
PILA
void adicionar(dato pil[],int *top,char
nom[],int ed,long codigo)
{
if(*top==) 10
{
cout<<" PILA LLENA ";
} EN ESTA PILA SOLO SE PUEDEN
else ALMACENAR 10 DATOS PS SU TOPE ES
{ IGUAL A 10
strcpy (pil[tope].nombre,nom);
pil[tope].edad=ed;
pil[tope].codigo=codigo;
cout<<" REGISTRO REALIZADO ";
tope++;
}
}
PROCEDIMIENTO
maria
strcpy (pil[tope].nombre,nom); 18
pil[tope].edad=ed;
pil[tope].codigo=codigo;
0123
cout<<" REGISTRO REALIZADO ";
REGISTRO REALIZADO
32
cout<<" PILA VACIA ";
} 1234
else
{
for(i=0;i<tope;i++)
{
gotoxy(5,f-2); cout<<" NOMBRE: "<<pila[i].nombre;
gotoxy(5,f-1); cout<<" EDAD: "<<pila[i].edad;
gotoxy(5,f);cout<<" CODIGO: "<<pila[i].codigo;
f=f-4;
}
}
getch();
}
void eliminar(char cadena[])
{
int i,j;
if(tope==0)
{
cout<<" PILA VACIA ";
}
else
{
for(i=0;i<tope;i++)
{
if(strcmp (cadena,pila[i].nombre)==0)
{
for(j=tope-1;j>i;j--)
{
adicionar(pilaaux,&topeaux,pila[j].nombre,pila[j].edad,pila[j].codigo);
atender(&tope);
}
tope=tope-1;
for(j=topeaux-1;j>=0;j--)
{
adicionar(pila,&tope,pilaaux[j].nombre,pilaaux[j].edad,pilaaux[j].codigo);
atender(&topeaux);
}
break;
TERCERA FUNCION
}
}
ELIMINAR if(i==tope)
cout<<" ESTA ELIMINADO ";
}
}
CUARTA FUNCION ESTADO DE LA PILA
LA PILA TIENE 2 ELEMENTOS void estado_pila()
{
clrscr();
if(tope==0)
{
gotoxy(12,12);
cout<<" LA PILA NO TIENE
ELEMENTOS ";
}
else
{
gotoxy(12,10);
cout<<" LA PILA TIENE "<<tope<<"
ELEMENTOS ";
}
getch();
}
QUINTA FUNCION ATENDER UN ELEMENTO
void atender(int *top) ELEMENTO ATENDIDO
{
if(*top==0)
{
cout<<" NO HAY ELEMENTOS ";
}
else
{
*top=*top-1;
cout<<" ELEMENTO ATENDIDO ";
}
getch();
}