第一范文网 - 专业文章范例文档资料分享平台

预测分析算法的设计与实现

来源:用户分享 时间:2025/5/25 0:49:14 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

.

pt->nVt = nCh; pt->next = NULL;

if(NULL == first[U - 100]) {

first[U - 100] = pt; } else {

qt->next = pt; /*qt指向first集的最后一个元素*/ }

pt = pt->next; } } else {

pt = first[nCh - 100]; while(NULL != pt) {

ch = pt->nVt; if(-1 != ch) {

AddFirst(U, ch); }

pt = pt->next; } } }

bool HaveEmpty(int nVn) {

if(nVn < 100) return false;

struct collectNode *pt; pt = first[nVn - 100]; while(NULL != pt) {

if(-1 == pt->nVt) return true;

11 / 24'.

.

pt = pt->next; }

return false; }

void Follow(int V) { int i;

struct pRNode *pt ;

if(100 == V) /*当为初始符时*/ AddFollow(V, -1, 0 ); for(i = 0; i < PNum; i++) {

pt = P[i].rHead;

while(NULL != pt && pt->rCursor != V) pt = pt->next; if(NULL != pt) {

pt = pt->next; if(NULL == pt) {

if(NULL == follow[P[i].lCursor - 100] && P[i].lCursor != V) {

Follow(P[i].lCursor); }

AddFollow(V, P[i].lCursor, 0); } else {

while(NULL != pt && HaveEmpty(pt->rCursor)) {

AddFollow(V, pt->rCursor, 1); pt = pt->next; }

if(NULL == pt) {

if(NULL == follow[P[i].lCursor - 100] && P[i].lCursor != V) {

12 / 24'.

.

Follow(P[i].lCursor); }

AddFollow(V, P[i].lCursor, 0); } else {

AddFollow(V, pt->rCursor, 1); } } } } }

void AddFollow(int V, int nCh, int kind) {

struct collectNode *pt, *qt; int ch; pt = NULL; qt = NULL;

if(nCh < 100) /*为终结符时*/ {

pt = follow[V - 100]; while(NULL != pt) {

if(pt->nVt == nCh) break; else {

qt = pt; pt = pt->next; } }

if(NULL == pt) {

pt = (struct collectNode *)malloc(sizeof(struct collectNode)); pt->nVt = nCh; pt->next = NULL;

if(NULL == follow[V - 100])

13 / 24'.

.

{

follow[V - 100] = pt; } else {

qt->next = pt; /*qt指向follow集的最后一个元素*/ }

pt = pt->next; } } else {

if(0 == kind) {

pt = follow[nCh - 100]; while(NULL != pt) {

ch = pt->nVt;

AddFollow(V, ch, 0); pt = pt->next; } } else {

pt = first[nCh - 100]; while(NULL != pt) {

ch = pt->nVt; if(-1 != ch) {

AddFollow(V, ch, 1); }

pt = pt->next; } } } }

/*输出first或follow集*/

14 / 24'.

.

void ShowCollect(struct collectNode **collect) { int i;

struct collectNode *pt; i = 0;

while(NULL != collect[i]) {

pt = collect[i];

printf(\ while(NULL != pt) {

if(-1 != pt->nVt) {

printf(\ } else

printf(\ pt = pt->next; } i++; }

printf(\}

/*计算first和follow*/ void FirstFollow() { int i; i = 0;

while('\\0' != Vn[i]) {

if(NULL == first[i]) First(100 + i); i++; } i = 0;

while('\\0' != Vn[i]) {

if(NULL == follow[i])

15 / 24'.

搜索更多关于: 预测分析算法的设计与实现 的文档
预测分析算法的设计与实现.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1udi3733in7yqpo85se79mzf00wrvr00ivk_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top