云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 数据结构大作业之家谱管理系统

数据结构大作业之家谱管理系统

  • 62 次阅读
  • 3 次下载
  • 2025/7/15 9:55:10

Member *p = (*i)->pson; while (p->pbro!=nullptr) p = p->pbro; p->pbro = temp; } next.push_back(temp); temp = nullptr; break; } } //若成员的父亲不是这一代的成员,则将next赋予genely,迭进下一代 if (temp != nullptr){ genely = next;//迭进下一代 next.clear();//清空next for (auto i : genely){//将成员放入家族树中 if (i->name == temp->father){ i->pson = temp; next.push_back(temp); temp = nullptr; break; } } } //动态创建临时成员变量,用于存储输入的下一个成员的信息

temp = new Member; } infile.close();//关闭存储成员信息的文件 //若文件中没有成员信息,将root置为空 if (root->name == \未知\) root = nullptr; //打开存储家庭总体信息的文件,读入信息 infile.open(\, ios::in | ios::_Nocreate); if (!infile){ return false; } infile >> total >> aveAge >> aveHeight >> aveMember >> ratio; infile.close();//关闭文件 return true; } Member *FamilySystem::seek(string nam){ //若家谱树为空,返回空指针 if (root == nullptr) return nullptr; //若root不为空,继续查找 Member *store = nullptr;//存储返回的指针 vector genely;//存储这一代的指针 genely.push_back(root); vector next;//存储下一代的指针 for (;;){//循环查找 //在这一代中查找,若找到,跳到最后 for (auto p : genely){ if (p->name == nam){ store = p; goto End; } } //判断下一代是否为空,若为空,跳到最后 int jubge = 0; for (auto p : genely){ if (p->pson != nullptr) ++jubge; } if (jubge == 0) goto End; //找到下一代 for (auto p : genely){ Member *temp = p->pson; if (temp==nullptr) continue; else{ next.push_back(temp); while (temp->pbro != nullptr){ next.push_back(temp->pbro); temp = temp->pbro; } } } genely = next; next.clear(); } End:return store; } bool FamilySystem::addMem(){ cout << \添加成员.\\n\; Member *temp=new Member; try{ temp->setE();//输入成员信息 } catch (int){ return false; } //检查其父亲是否存在 Member *jubge = seek(temp->father); if (root == nullptr) root = temp; else if (jubge == nullptr){ cout << \家谱中没有此人父亲的信息!无法插入!\; cout << \请确认此人是否此家族中的人!\;

搜索更多关于: 数据结构大作业之家谱管理系统 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

Member *p = (*i)->pson; while (p->pbro!=nullptr) p = p->pbro; p->pbro = temp; } next.push_back(temp); temp = nullptr; break; } } //若成员的父亲不是这一代的成员,则将next赋予genely,迭进下一代 if (temp != nullptr){ genely = next;//迭进下一代 next.clear();//清空next for (auto i : genely){//将成员放入家族树中 if (i->name == temp->father){ i->pson = temp; next.push_back(

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com