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

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

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

  • 62 次阅读
  • 3 次下载
  • 2025/7/15 19:16:27

} bool FamilySystem::saveFile(){ ofstream outfile; //打开保存家庭信息的文件,并写入信息 outfile.open(\, ios::out); if (!outfile){ return false; } calculate(); outfile << total << \ << aveAge << \ << aveHeight << \ << aveMember << \ << ratio; outfile.close(); //打开保存家庭成员信息的文件并写入信息 outfile.open(\, ios::out); if (!outfile){ return false; } vector genely;//保存一代成员的指针 genely.push_back(root); while (1){ //输出这一代成员的信息 for (auto p : genely){ if (p != nullptr){ outfile << p->name << \\ << p->birthPlace << \ \

<< p->birthDay << \ << p->sex << \ << p->height << \ << p->age << \ << p->job << \ << p->education << \ << p->father << endl; } } //计算这一代成员的儿女的人数 //若这一代都没有儿女,则退出 int jubge = 0; for (auto p : genely){ if (p != nullptr){ if (p->pson != nullptr) ++jubge; } } if (jubge == 0) break; //找到下一代的成员,即这一代的儿女 vector next; for (auto p : genely){ Member *temp=p->pson; if (temp!= nullptr){ next.push_back(temp); while (temp->pbro != nullptr){ next.push_back(temp->pbro); temp = temp->pbro; } } } genely = next;//迭进下一代 next.clear(); } return true; }

主函数及欢迎界面的实现 #include #include\ using std::cout; using std::endl; using std::flush; int main(){ //显示系统欢迎界面 void welcome(); system(\);//将系统背景颜色置为黑色,前景暗绿色 welcome(); //画面停留3秒 const time_t start = time(0); while (1){ time_t current = time(0); if (current - start == 3) break; } FamilySystem genealogy;//程序唯一的一个家谱对象 //从文件中读取出家庭成员的信息,若读取不成功,则强制退出程序 if (!genealogy.fileInit()){ system(\); //输出错误信息 for (int i = 0; i != 10; ++i) cout << \; string str = \; cout <

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

共分享92篇相关文档

文档简介:

} bool FamilySystem::saveFile(){ ofstream outfile; //打开保存家庭信息的文件,并写入信息 outfile.open(\, ios::out); if (!outfile){ return false; } calculate(); outfile << total << \ << aveAge << \ << aveHeight << \ << aveMember << \ << ratio; outfile.close(); //打开保存家庭成员信息的文件并写入信息 outfile.open(\, ios::out); if (!outfile){ return false; } vector genely;//保存一代成员的指针 genely.push_back(ro

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