Documentos de Académico
Documentos de Profesional
Documentos de Cultura
# define OK 0
# define ERROR -1
# define FALSO 0
# define VERDADERO 1
# define LLENA 1
# define PILAMAX 100
# define ADENTRO 1
# define AFUERA 0
# include <stdio.h>
int pila[PILAMAX];
return( LLENA);
return( OK);
int extraer()
{ // La funcion extrae elementos de la pila
return( pila[superior--] );
int vacio()
{ // Abre vacio
if( superior < 0 )
return(VERDADERO);
return(FALSO);
} // Cierra vacio
int i;
int comentario = AFUERA;
// Este ciclo for pasa por alto los caracteres que no sean parentesis
// Los parentesis de apertura se guardan en una pila
{ // ABre for
switch( datos[i])
{ // ABre switch
case '{':
case '[':
case '(':
if ( AFUERA == comentario )
{
empujar( datos[i]);
break;
case '}':
if ( AFUERA == comentario )
return (ERROR);
break;
case ']':
if ( AFUERA == comentario )
return (ERROR);
break;
case ')':
if ( AFUERA == comentario )
return (ERROR);
break;
case '/':
if ( AFUERA == comentario )
{
if ( '*' == datos[i + 1] )
comentario = ADENTRO;
if (ADENTRO == comentario)
comentario = AFUERA;
break;
} // Cierra switch
} // Cierra for
if ( ADENTRO == comentario )
return (ERROR);
if ( vacio())
return (OK);
return (ERROR);
int main()
{ // Abre main
int cadena[PILAMAX];
int c;
int x = 0;
int j;
j = Revisa_Parentesis( cadena);
if ( OK == j )
printf("\nLos parentesis estan bien escritos.\n");
else
if( ERROR == j )
} // Cierra main