今天很忙,但晚上才有时间完善自己的项目,感觉自己的项目好菜,但还是要好好做好现在,关于项目我有了基本思路:
1:可以对性别筛选,再来对姓名筛选
2:可以存入文件
3:可以对姓名和电话直接查,直接上代码了
void findperson(addressbooks *abs) {
cout << "请输入您要查找的方式:姓名 性别 电话 年龄" << endl;
string n;
cin >> n;
if (n == "姓名") {
cout << "请输入您要查找的人的姓名:" << endl;
string name;
cin >> name;
int ret = i(abs, name);
if (ret != -1) {
cout << "姓名:" << abs->perponshu[ret].xinming << endl;
cout << "性别:" << abs->perponshu[ret].sex << endl;
cout << "年龄:" << abs->perponshu[ret].age << endl;
cout << "电话号码:" << abs->perponshu[ret].nummber << endl;
cout << "家庭住址:" << abs->perponshu[ret].zhuzhi << endl;
cout << endl;
} else {
cout << "未找到相关联系人的信息:" << endl;
}
} else if (n == "性别") {
cout << "请输入您要查找的人的姓别:" << endl;
string sex;
cin >> sex;
int ret = q(abs, sex);
if (ret != -1) {
for (int i = 0; i < abs->size; i++) {
if (abs->perponshu[i].sex == sex) {
cout << "姓名:" << abs->perponshu[i].xinming << endl;
cout << "性别:" << abs->perponshu[i].sex << endl;
cout << "年龄:" << abs->perponshu[i].age << endl;
cout << "电话号码:" << abs->perponshu[i].nummber << endl;
cout << "家庭住址:" << abs->perponshu[i].zhuzhi << endl;
cout << endl;
}
}
cout << "未找到联系人??是否还要继续寻找:是的话点1:否的话点2:" << endl;
int shifuo;
cin >> shifuo;
if (shifuo == 1) {
cout << "亲输入你要寻找的方式:年龄 电话 姓名" << endl;
string xing;
cin >> xing;
if (xing == "年龄") {
cout << "请输入您要查找的联系人的年龄:" << endl;
int age;
cin >> age;
if (ret != -1) {
for (int i = 0; i < abs->size; i++) {
if (abs->perponshu[i].sex == sex && abs->perponshu[i].age == age) {
cout << "姓名:" << abs->perponshu[i].xinming << endl;
cout << "性别:" << abs->perponshu[i].sex << endl;
cout << "年龄:" << abs->perponshu[i].age << endl;
cout << "电话号码:" << abs->perponshu[i].nummber << endl;
cout << "家庭住址:" << abs->perponshu[i].zhuzhi << endl;
cout << endl;
}
}
}
} else if (xing == "电话") {
cout << "请输入您要查找的联系人的电话:" << endl;
string nummber;
cin >> nummber;
if (ret != -1) {
for (int i = 0; i < abs->size; i++) {
if (abs->perponshu[i].sex == sex && abs->perponshu[i].nummber == nummber) {
cout << "姓名:" << abs->perponshu[i].xinming << endl;
cout << "性别:" << abs->perponshu[i].sex << endl;
cout << "年龄:" << abs->perponshu[i].age << endl;
cout << "电话号码:" << abs->perponshu[i].nummber << endl;
cout << "家庭住址:" << abs->perponshu[i].zhuzhi << endl;
cout << endl;
}
}
}
} else if (xing == "姓名") {
cout << "请输入您要查找的联系人的姓名:" << endl;
string xinming;
cin >> xinming;
if (ret != -1) {
for (int i = 0; i < abs->size; i++) {
if (abs->perponshu[i].sex == sex && abs->perponshu[i].xinming == xinming) {
cout << "姓名:" << abs->perponshu[i].xinming << endl;
cout << "性别:" << abs->perponshu[i].sex << endl;
cout << "年龄:" << abs->perponshu[i].age << endl;
cout << "电话号码:" << abs->perponshu[i].nummber << endl;
cout << "家庭住址:" << abs->perponshu[i].zhuzhi << endl;
cout << endl;
}
}
}
} else {
cout << "未找到相关联系人的信息:" << endl;
}
}
}
} else if (n == "电话") {
cout << "请输入您要查找的人的号码:" << endl;
string nummber;
cin >> nummber;
这是今晚的努力的成果,但愿吧!!!



