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

#include #include #include #include #include #include\ using std::cin; using std::cout; using std::endl; using std::setw; using std::vector; using std::ios; using std::ifstream; using std::ofstream; using std::istringstream; string gets(){//从控制台获取字符等信息 string s; while (int n = _getch()){ if (n == 27){ throw 27; break; } else if (n == 13){ cout << endl; break; } else if (n == 8){ s.pop_back(); cout << \; } else{ cout << char(n); s.push_back(char(n)); } } return s; } //与BirthDay相关的函数 istream &operator>>(istream &in, BirthDay &b){//从文件中读取生日的信息 in >> b.year >> b.month >> b.day; return in; } ostream &operator<<(ostream &out, BirthDay &b){ out << b.year << \ << b.month << \ << b.day; return out; } //与Member相关的函数 void Member::setE(){ try{ istringstream sin; cout << setw(20) << \请输入成员信息:\\n\ << endl << setw(20) << \姓名:\; sin.str(gets()); sin >> name; cout << endl << setw(20) << \出生地:\;

sin.str(gets()); sin.clear(); sin >> birthPlace; cout << endl << setw(20) << \生日:\; sin.str(gets()); while (true){ sin.clear(); sin >> birthDay.year >> birthDay.month >> birthDay.day; if ( !sin||birthDay.year > 2014 || birthDay.month > 12 || birthDay.day > 31){ cout << \输入错误,请重新输入:\; sin.str(gets()); } else break; } cout << endl << setw(20) << \性别:\; sin.str(gets()); sin.clear(); while (sin >> sex){ if (sex == \ || sex == \ || sex == \男\ || sex == \女\) break; else{ cout << \性别必须是male、female、男或者女,请重新输入:\; sin.str(gets()); sin.clear(); } } cout << endl << setw(20) << \身高(厘米):\; sin.str(gets()); sin.clear(); while (!(sin >> height)){ cout << \输入错误,请重新输入:\; sin.str(gets()); sin.clear(); } cout << endl << setw(20) << \年龄:\; sin.str(gets()); sin.clear(); while (!(sin >> age) || age > 300){ cout << \输入错误,请重新输入:\ << endl; sin.str(gets()); sin.clear(); } cout << endl << setw(20) << \学历:\;

sin.str(gets()); sin.clear(); sin >> education; cout << endl << setw(20) << \工作:\; sin.str(gets()); sin.clear(); sin >> job; cout << endl << setw(20) << \父亲:\; sin.str(gets()); sin.clear(); sin >> father; } catch (int ex){ throw ex; } return; }

联系客服:779662525#qq.com(#替换为@)