文档介绍:#include<>
#include ""
void main( )
{
char ch,temp;
SeqStack s;
InitStack(&s);
scanf("%c",&ch);
while(ch!='@'&&ch!='&')
{
Push(&s,ch);
scanf("%c",&ch);
}
while(ch!='@'&&!IsEmpty(&s))
{
Pop(&s,&temp);
scanf("%c",&ch);
if(ch!=temp)
break;
}
if(!IsEmpty(&s))
printf("no!\n");
else
{
scanf("%c",&ch);
if(ch=='@') printf("yes!\n");
else printf("no!\n");
} }
数值转换
#include<>
#include<>
#include<>
typedef struct
{
DataType stack[MaxStackSize];
int top;
} SeqStack;
void StackInitiate(SeqStack *S)
{
S->top = 0;
}
//(2)非空否StackNotEmpty(S)
int StackNotEmpty(SeqStack S)
{
if( <= 0) return 0;
else return 1;
}
//(3)入栈StackPush(S, x)
int StackPush(SeqStack *S, DataType x)
{
if(S->top >= MaxStackSize)
{ printf("堆栈已满无法插入! \n");
return 0;
}
else
{ S->stack[S->top] = x;
S->top ++;
return 1;
}
}
//(4)出栈StackPop(S, d)
int StackPop(SeqStack *S, DataType *d)
{
if(S->top <= 0)
{ printf("堆栈已空无数据元素出栈! \n");
return 0;
}
else
{ S->top --;
*d = S->stack[S->top];
return 1;
}
}
//(5)取栈顶数据元素StackTop(SeqStack S, DataType *d)
i
nt StackTop(SeqStack S, DataType *d)
{
if( <= 0)
{ printf("堆栈已空! \n");
return 0;
}
else
{ *d = [ - 1];
return 1;
}
}
#include<>
#include<s