/**
* 实验题目:
* 实现广义表的基本运算
* 实验内容:
* 实现广义表的各种运算,设计一个程序,实现如下功能:
* 1、建立广义表g = "((b,a),(((a,b),c),d))"的链式存储结构
* 2、输出广义表g的长度
* 3、输出广义表g的深度
*/
#include <stdio.h>
#include <malloc.h>
typedef char ElemType;
typedef struct lnode
{
int tag; // 结点类型标识
union
{
ElemType data;
struct lnode *sublist;
}val;
struct lnode *link; // 指向下一个元素
}GLNode;
/*----------------------------由串s建立一个广义表-------------------------*/
GLNode *CreateGL(char *&s) // 指针的引用
{
GLNode *h;
char ch;
//(b,(b,a,a,a),((a,b),c))
ch = *s++; // 取一个扫描字符(先取值,然后s指向下一个字符)
// printf("%s line = %d, ch = %c\n", __func__, __LINE__, ch);
if(ch != '\0') &nbs