黑马程序员通讯录管理系统c++
时间: 2023-09-22 22:12:40 浏览: 134
黑马程序员通讯录管理系统C++是一个用于管理通讯录联系人信息的系统。在该系统中,可以进行添加联系人、显示联系人、删除联系人、查找联系人、修改联系人、清空通讯录等功能。
在系统的实现思路中,清空通讯录的方法是通过将通讯录记录的联系人数量置为0来实现逻辑清空。具体的代码实现如下:
```
void cleanPerson(Addressboks * abs) {
cout << "您的通讯录是否清空?(Y/N)" << endl;
string select;
cin >> select;
while (true) {
if (select == "Y" || select == "y") {
abs->m_Size = 0; // 将当前记录联系人数量置为0,做逻辑清空操作
cout << "通讯录已清空" << endl;
} else if (select == "N" || select == "n") {
break;
} else {
cout << "输入有误" << endl;
break;
}
}
system("pause");
system("cls");
}
```
而测试清空联系人功能的方法是判断当前通讯录中是否有人员,若人数为0,则提示记录为空;若人数大于0,则显示通讯录中的信息。具体的代码实现如下:
```
void showPerson(Addressboks * abs) {
if (abs->m_Size == 0) {
cout << "通讯录为空" << endl;
} else {
for (int i = 0; i < abs->m_Size; i++) {
cout << "姓名:" << abs->personArray[i].m_Name << "\t";
cout << "性别:" << (abs->personArray[i].m_Sex == 1 ? "男" : "女") << "\t";
cout << "年龄:" << abs->personArray[i].m_Age << "\t";
cout << "电话:" << abs->personArray[i].m_Phone << "\t";
cout << "地址:" << abs->personArray[i].m_Addr << endl;
}
}
system("pause");
system("cls");
}
```
以上就是黑马程序员通讯录管理系统C++的相关介绍和功能实现方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [黑马程序员 C++ 通讯录管理系统 学习记录](https://blog.csdn.net/qq_49488584/article/details/124813814)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [day06-案例C++制作简单通讯录](https://blog.csdn.net/qq_39431829/article/details/102595151)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]