1 首先写函数
#include "fun.h"
//初始化,第一个存'\0'
void intstack(struct mystack *sp)
{
sp->top=0;
strcpy(sp->c,"\0");
}
//入栈
void push(struct mystack *sp,char c)
{
sp->c[sp->top]=c;
sp->top++;
}
//出栈
void pop(struct mystack *sp)
{
sp->top--;
}
//判断栈是否为空
int isEmpty(struct mystack *sp)
{
if(sp->top==0)
return 1;
else
return 0;
}
//清空栈
void clearstack(struct mystack *sp)
{
sp->top=0;
}
//显示站内数据
void printstack(struct mystack *sp)
{
int i=0;
for(;i<sp->top;i++)
{
sp->c[i];
printf("%c",sp->c[i]);
}
}
2写头文件
#include <stdio.h>
#incl