第九周项目4-广义表算法库及应用(2)
来源:互联网 发布:wifi网络受限怎么解决 编辑:程序博客网 时间:2024/06/16 01:06
问题及代码:
#include <stdio.h>#include "glist.h"int atomnum(GLNode *g) //求广义表g中的原子个数{ if (g!=NULL) { if (g->tag==0) return 1+atomnum(g->link); else return atomnum(g->val.sublist)+atomnum(g->link); } else return 0;}ElemType maxatom(GLNode *g) //求广义表g中最大原子{ ElemType max1,max2; if (g!=NULL) { if (g->tag==0) { max1=maxatom(g->link); return(g->val.data>max1?g->val.data:max1); } else { max1=maxatom(g->val.sublist); max2=maxatom(g->link); return(max1>max2?max1:max2); } } else return 0;}int main(){ GLNode *g; char *s="(b,(b,a,(#),d),((a,b),c((#))))"; g = CreateGL(s); DispGL(g); printf("\n"); printf("原子个数 :%d\n", atomnum(g)); printf("最大原子 :%c\n", maxatom(g)); return 0;}
glist.h同(1)
0 0
- 第九周-项目4-广义表算法库及应用
- 第九周 项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- (第九周项目4)广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周--项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周 项目4-广义表算法库及应用
- 第九周 项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 第九周项目4-广义表算法库及应用
- 【第九周项目4-广义表算法库及应用】
- 第九周 项目4 广义表算法库及应用
- RabbitMQ的使用
- Android自定义View之图形图像工具类Path的特殊用法
- python的简单实际应用(一)
- android 模拟滑动事件
- java 第三方库common系统详解
- 第九周项目4-广义表算法库及应用(2)
- hdu 5536 Chip Factory 2015长春区域赛 数据结构 Trie
- 阻塞非阻塞,同步与异步
- 漫谈 C++ 智能指针 01
- Linux文件系统简介
- [转载] shell awk入门
- Leetcode135: Simplify Path
- 第九周项目3-(1)稀疏矩阵的三元组表示
- Spring: @Transactional中的propagation属性