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

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

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

  • 62 次阅读
  • 3 次下载
  • 2025/7/15 15:06:24

void FamilySystem::calculate(){ //若家谱树为空,将各总体值置零 if (root == nullptr){ total = 0; aveAge = 0; aveHeight = 0; aveMember = 0; ratio = 0; return; } //若root不为空,继续 vector genely;//存储这一代的指针 genely.push_back(root); vector next;//存储下一代的指针 int girl = 0;//女性数 int family = 0;//家庭数 total = 0; aveAge = 0; aveHeight = 0;//initialize for (;;){//循环叠加各所需总体数据 //在这一代中 for (auto p : genely){ ++total; aveAge += p->age; aveHeight += p->height; if (p->sex == \ || p->sex == \女\) ++girl; } //判断下一代是否为空,若为空,跳到最后 int jubge = 0; for (auto p : genely){ if (p->pson != nullptr){ ++jubge; ++family; } } if (jubge == 0) goto cal; //找到下一代 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();//清空next } //计算最后结果 cal:total = total; aveAge /= total; aveHeight /= total; if (family == 0) family = 1; aveMember = static_cast(total) / static_cast(family); if (girl!=0) ratio = static_cast(total - girl) / static_cast(girl); else ratio = 0; //退出 return; } bool FamilySystem::demandAve(){ calculate(); cout << \查询家庭整体情况.\\n\; cout << endl << endl; cout << setw(30) << \家庭的整体情况如下:\\t\ << endl << endl << endl; cout << setw(30) << \总人数:\\t\ << total << endl << endl << endl; cout << setw(30) << \平均年龄:\\t\ << aveAge << endl << endl << endl; cout << setw(30) << \平均身高:\\t\ << aveHeight << endl << endl << endl; cout << setw(30) << \家庭平均人数:\\t\ << aveMember << endl << endl << endl; cout << setw(30) << \男女比例:\\t\ << ratio; if( ratio!=0 ) cout << \ << endl; else cout << endl; cout << \按ESC键返回菜单\; for (;;){ if (_getch() == 27) break; } return true; } bool FamilySystem::modifyMem(){ cout << \修改成员信息.\\n\\n\; cout << \请输入姓名:\; string na; try{ istringstream sin(gets()); sin >> na; } catch (int){ goto rend; } Member *temp = seek(na); if (temp == nullptr){ cout << \家谱中没有此人的信息!\\n\; goto end; } cout << \选择修改项:\\n\\n\; cout << \姓名 2.出生地点

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

共分享92篇相关文档

文档简介:

void FamilySystem::calculate(){ //若家谱树为空,将各总体值置零 if (root == nullptr){ total = 0; aveAge = 0; aveHeight = 0; aveMember = 0; ratio = 0; return; } //若root不为空,继续 vector genely;//存储这一代的指针 genely.push_back(root); vector next;//存储下一代的指针 int girl = 0;//女性数 int family = 0;//家庭数 total = 0; aveAge = 0; aveHeight = 0;//initialize for (;;){//循环叠加各所需总体数据 //在这一代中 for

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价: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