数据结构之广义表
#include<stdio.h>
//广义表的头尾链表存储结构
typedef int AtomType;
typedef enum NodeType{ATOM,LIST}ElemTag;//ATOM表示原子结点,LIST表示表节点
typedef struct GLNode{
ElemTag tag;
union{
AtomType atom;
struct List{
struct GLNode* hp,*tp;
} htp;
}atom_htp;
}GLNode,*GList;
//求广义表L的表头
GList Head(GList L)
{
if(L==NULL)
return NULL;
if(L->tag==ATOM)
exit(0);
else
return (L->atom_htp->htp->hp);
}
//求广义表L的表尾
GList Tail(GList L)
{
if(L==NULL)
return NULL;
if(L->tag==ATOM)
exit(0);
else
return (L->atom_htp->htp->tp);
}
//求广义表的长度
int Length(GList L)
{
int k=0;
GLNode* s;
if(L==NULL)
return NULL;
if(L->tag==ATOM)
exit(0);
s=L;
while(s!=NULL)
{
k++;
s=s->atom_htp->htp->tp;
}
return k;
}
//求广义表的深度
int Depth(GList L)
{
}
亲爱的听众朋友我是你的代班DJ

浙公网安备 33010602011771号