#include <iostream>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define MAX 225
using namespace std;
typedef unsigned char Sstring [MAX+1];
typedef enum{ATOM,LIST}eleflag;
typedef struct node
{
eleflag tag;
union
{
int atom;
struct
{
struct node* hp,*tp;
}ptr;
}a;
}GLNode,*GList;
void create(Sstring &s,char *str)
{
int i;
for(i=0;str[i]!='\0';i++)
{
s[i+1]=*(str+i);
}
s[0]=(int)(strlen(str));
}
bool empty(Sstring &s)
{
if(s[0]==0)
return true;
else
return false;
}
void traverse(Sstring &s)
{
int i;
for(i=1;i<=s[0];i++)
cout<<s[i];
}
void substr(Sstring &s,Sstring &sub,int pos,int len)
{
int i;
if(pos<0 || len<0 || len>s[0]-pos+1)
cout<<"error";
fo
广义表头尾链表(未完)
最新推荐文章于 2023-09-14 22:23:43 发布
这篇博客主要介绍了如何使用C++实现广义表的头尾链表,包括创建、遍历、截取、比较等操作。通过示例代码展示了如何处理广义表中的原子和子表,并提供了广义表的输入与输出方法。
摘要由CSDN通过智能技术生成