以文本方式查看主题 - 计算机科学论坛 (http://bbs.xml.org.cn/index.asp) -- 『 C/C++编程思想 』 (http://bbs.xml.org.cn/list.asp?boardid=61) ---- [讨论]为何求深度会出现时会出现debug error! (http://bbs.xml.org.cn/dispbbs.asp?boardid=61&rootid=&id=17842) |
-- 作者:oceanblue -- 发布时间:5/3/2005 1:04:00 PM -- [讨论]为何求深度会出现时会出现debug error! #define HEAD 0 #define INTGR 1 #define CH 2 #define LST 3 #define NULL 0 #include <iostream.h> #include <stdlib.h> #include<string.h> class GenList; class GenListNode { friend class GenList; private: int utype; GenListNode *tlink; union { int ref; int intginfo; char charinfo; GenListNode *hlink; }value; public: int nodetype(GenListNode *elem) { return elem->utype; } int Getvalue()const { return utype; } }; class GenList { private: GenListNode* first; void Remove(GenListNode *ls); //friend int operator==(const GenList &l,const GenList &m); GenListNode &Head(); int Createlist(GenListNode *&ls,char *s); int GenList::depth(GenListNode *ls) { if(ls->tlink==NULL)return 1; GenListNode *temp=ls->tlink; int m=0; while(temp!=NULL) { if(temp->utype==LST) { int n=depth(temp->value.hlink); if(m<n)m=n; } temp=temp->tlink; } return m+1; }
int GenList::Createlist(GenListNode * &ls,char *s) ls=new GenListNode(); while(strlen(sub)!=0) { p=p->tlink=new GenListNode(); if(sever(sub,hsub)) { p->utype=INTGR; else if(hsub[0]!='('&&hsub[0]=='\'') { else { } } else return 0; } p->tlink=NULL; { char ch=str1[0]; int n=strlen(str1); int i=0,k=0; { if(ch=='(')k++; else if( ch == ')')k--; i++; ch=str1[i]; } if(i<n) strncpy( hstr1 , str1 , i); cout<<hstr1<<endl; return 1; } return 1;
} void main() |
-- 作者:oceanblue -- 发布时间:5/3/2005 1:07:00 PM -- 欢迎大家来讨论! |
-- 作者:oceanblue -- 发布时间:5/5/2005 9:45:00 AM -- #define HEAD 0 #define INTGR 1 #define CH 2 #define LST 3 #define NULL 0 #include <iostream.h> #include <stdlib.h> #include<string.h> class GenList; class GenListNode { friend class GenList; private: int utype; GenListNode *tlink; union { int ref; int intginfo; char charinfo; GenListNode *hlink; }value; public: int nodetype(GenListNode *elem) { return elem->utype; } int Getvalue()const { return utype; } }; class GenList { private: GenListNode* first; void Remove(GenListNode *ls); //friend int operator==(const GenList &l,const GenList &m); GenListNode &Head(); int Createlist(GenListNode *&ls,char *s); int GenList::depth(GenListNode *ls) { if(ls->tlink==NULL)return 1; GenListNode *temp=ls->tlink; int m=0; while(temp!=NULL) { if(temp->utype==LST) { int n=depth(temp->value.hlink); if(m<n)m=n; } temp=temp->tlink; } return m+1; }
int GenList::Createlist(GenListNode * &ls,char *s) ls=new GenListNode(); while(strlen(sub)!=0) { p=p->tlink=new GenListNode(); if(sever(sub,hsub)) { p->utype=INTGR; else if(hsub[0]!='('&&hsub[0]=='\'') { else { } } else return 0; } p->tlink=NULL; { char ch=str1[0]; int n=strlen(str1); int i=0,k=0; { if(ch=='(')k++; else if( ch == ')')k--; i++; ch=str1[i]; } if(i<n) strncpy( hstr1 , str1 , i); return 1; } return 1;
} void main() |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
79.102ms |