#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#define lg_max 5
typedef struct
int varf;
tip_elem elemente[lg_max];
}STIVA;
int er, j, i;
STIVA S;
tip_elem X;
S->varf=lg_max;
} /* Initializare */
int stiva_vida(STIVA S)
if(S.varf>=lg_max)
return 1;
else return 0;
} /* stiva_vida */
tip_elem varf_st(STIVA S)
er=0;
if(stiva_vida(S) == 1)
er=1;
return 0;
} /* varf_st */
er=0;
if(stiva_vida(*S)==1)
er=1;
printf("ERROR. Stiva este vida!! \n");
else
*X=S->elemente[S->varf];
S->elemente[S->varf]=0;
S->varf=S->varf+1;
} /* Sterge */
er=0;
if(S->varf==0)
er=1;
else
S->varf=S->varf-1;
S->elemente[S->varf]=X;
} /* Adauga */
void creare(void)
char c;
initializare(&S);
while(c=='D')
adauga(X, &S);
} /* Creare */
void listare(STIVA S)
int i;
if(stiva_vida(S))
er=1;
else
{
printf("\n Stiva : ");
} /* Listare */
void listare_Tab(void)
printf("Tabloul: [ ");
} /* Listare_Tab */
int i;
if(S.elemente[i]==X)
return i;
return -1;
} /* Cautare */
void main(void)
{
tip_elem X;
char op;
initializare(&S);
do
clrscr();
printf("C-Creare. \n");
printf("L-Listare. \n");
printf("G-Cautare. \n");
printf("S-Stergere. \n");
printf("E-Iesire. \n\n");
switch(op)
break;
if(er==0)
break;
adauga(X, &S);
break;
break;
else
fflush(stdin); scanf("%d",&X);
j=cautare(X, S);
if(j!=lg_max)
else
break;
break;
} /* SWITCH */
listare(S);
listare_Tab();
getch();
}while(op!='E');
} /* MAIN */