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

2018-11-19 20:43

temp->birthPlace; cout << \请输入更改:\; cin >> temp->birthDay; break; case 51: cout << \生日原为:\ << temp->birthDay; cout << \请输入更改:\; cin >> temp->birthDay; break; case 52: cout << \性别原为:\ << temp->sex; cout << \请输入更改:\; cin >> temp->sex; while (temp->sex != \&&temp->sex != \&& temp->sex != \男\&&temp->sex != \女\){ cout << \输入错误,性别必须为male、female、男或女!\\n请重新输入:\; cin >> temp->sex; } break; case 53: cout << \身高原为:\ << temp->height; cout << \请输入更改:\; cin >> temp->height; break; case 54: cout << \年龄原为:\ << temp->age; cout << \请输入更改:\; cin >> temp->age; break; case 55: cout << \学历原为:\ << temp->education; cout << \请输入更改:\; cin >> temp->education; break; case 56: cout << \工作原为:\ << temp->job; cout << \请输入更改:\; cin >> temp->job; break; default:; } cout << \修改成功!\; } end:cout<<\按ESC键返回菜单\; for (;;){ if (_getch() == 27) break; } rend:return true; } void FamilySystem::display(Member *r, int n){ string blank=\; for (int i = 0; i != n; ++i) blank += \; cout << blank<name<pson!=nullptr) display(r->pson, n + 6); if (r->pbro != nullptr) display(r->pbro, n); return; } bool FamilySystem::showFamily(){ cout << \显示整个家谱.\\n\\n\; if (root == nullptr) cout << \家谱为空!\\n\\n\; else display(root, 0); //escape cout << \按ESC键返回菜单\; for (;;){ if (_getch() == 27) break; } return true; } 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);


数据结构大作业之家谱管理系统(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:入户门制安工程招标文件

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: