这是其他代码··请问主函数该怎样写?

[复制链接]
查看11 | 回复1 | 2010-11-30 14:13:56 | 显示全部楼层 |阅读模式
编写顺序栈的基本操作函数,并保存在stack.h文件中,在main中通过调用该头文件中的函数实现对栈的基本操作
#define TRUE 1
#define FALSE 0
#define Stack_Size 50
typedef struct
{
StackElementType elem[Stack_Size];
int top;
}SeqStack;
void InitStack(SeqStack *S)
{
S->top=-1;
}
int IsEmpty(SeqStack *S)
{
return(S->top==-1?TRUE:FALSE);
}
int IsFull(SeqStack *S)
{
return(S->top==Stack_Size-1?TRUE:FALSE);
}
int Push(SeqStack *S,StackElementType x)
{
if(S->top==Stack_Size-1)return(FALSE);
S->top++;
S->elem[S->top]=x;
return(TRUE);
}
int Pop(SeqStack *S,StackElementType *x)
{
if(S->==-1)return(FLASE);
else
{*x=S->elem[S->top];
S->top--;
return(TRUE);
}
int GetTop(SeqStack *S,StackElementType *x)
{
if(S->top==-1)return(FLASE);
else
{ *x=S->elem[S->top];
return(TRUE);
}
int main()
{
SeqStack *S;
int x,s;
Seq=Init_Seqstack();

printf("请输入要插入的元素个数:");

回复

使用道具 举报

千问 | 2010-11-30 14:13:56 | 显示全部楼层
你在主函数里面创建一个链表,然后把链表头指针(假设你的L是头指针)和查找数作为参数直接就调用了呗~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行