C++实现通讯录管理系统
本文实例为大家分享了C++通讯录管理系统的具体代码,供大家参考,具体内容如下
#include#include usingnamespacestd; #defineMAX1000 structPerson { stringm_Name; intm_Sex; intm_Age; stringm_Phone; stringm_Addr; }; structAddressbooks { structPersonpersonArray[MAX]; intm_Size; }; voidaddPerson(Addressbooks*abs) { if(abs->m_Size==MAX) { cout<<"通讯录已满,无法添加!"< >name; abs->personArray[abs->m_Size].m_Name=name; cout<<"请输入性别:"< >sex; if(sex==1||sex==2) { abs->personArray[abs->m_Size].m_Sex=sex; break; } cout<<"输入有误,请重新输入!"< >age; abs->personArray[abs->m_Size].m_Age=age; cout<<"请输入联系电话:"< >phone; abs->personArray[abs->m_Size].m_Phone=phone; cout<<"请输入家庭住址:"< >address; abs->personArray[abs->m_Size].m_Addr=address; abs->m_Size++; cout<<"添加成功"< m_Size==0) { cout<<"当前记录为空"< m_Size;i++) { cout<<"姓名:"< personArray[i].m_Name<<"\t"; cout<<"性别:"<<(abs->personArray[i].m_Sex==1?"男":"女")<<"\t"; cout<<"年龄:"< personArray[i].m_Age<<"\t"; cout<<"电话:"< personArray[i].m_Phone<<"\t"; cout<<"住址:"< personArray[i].m_Addr< m_Size;i++) { if(abs->personArray[i].m_Name==name) { returni; } } return-1;//没找到 } //删除联系人 voiddeletePerson(Addressbooks*abs) { cout<<"请输入要删除的联系人:"< >name; intret=isExist(abs,name); if(ret!=-1) { for(inti=ret;i m_Size;i++) { abs->personArray[i]=abs->personArray[i+1]; } abs->m_Size--; cout<<"删除成功!"< >name; intret=isExist(abs,name); if(ret!=-1) { cout<<"姓名:"< personArray[ret].m_Name<<"\t"; cout<<"性别:"<<(abs->personArray[ret].m_Sex==1?"男":"女")<<"\t"; cout<<"年龄:"< personArray[ret].m_Age<<"\t"; cout<<"电话:"< personArray[ret].m_Phone<<"\t"; cout<<"住址:"< personArray[ret].m_Addr< >name; intret=isExist(abs,name); if(ret!=-1) { stringname; cout<<"请输入姓名:"< >name; abs->personArray[ret].m_Name=name; cout<<"请输入性别:"< >sex; if(sex==1||sex==2) { abs->personArray[ret].m_Sex=sex; break; } cout<<"输入有误,请重新输入!"< >age; abs->personArray[ret].m_Age=age; cout<<"请输入联系电话:"< >phone; abs->personArray[ret].m_Phone=phone; cout<<"请输入家庭住址:"< >address; abs->personArray[ret].m_Addr=address; cout<<"修改成功"< m_Size=0; cout<<"通讯录已清空"< >select; switch(select) { case1://添加联系人 addPerson(&abs); break; case2://显示联系人 showPerson(&abs); break; case3://删除联系人 /*{ cout<<"请输入删除联系人姓名:"< >name; if(isExist(&abs,name)==-1) { cout<<"查无此人"< 更多学习资料请关注专题《管理系统开发》。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。