C++實現(xiàn)通訊錄管理系統(tǒng)項目_第1頁
C++實現(xiàn)通訊錄管理系統(tǒng)項目_第2頁
C++實現(xiàn)通訊錄管理系統(tǒng)項目_第3頁
C++實現(xiàn)通訊錄管理系統(tǒng)項目_第4頁
C++實現(xiàn)通訊錄管理系統(tǒng)項目_第5頁
已閱讀5頁,還剩6頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

第C++實現(xiàn)通訊錄管理系統(tǒng)項目本文實例為大家分享了C++實現(xiàn)通訊錄管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

1、通訊錄設(shè)計要點

1:添加聯(lián)系人:向通訊錄中添加新人(包括:性別,年齡,聯(lián)系電話,家庭住址),并且最多記錄1000人

2:顯示聯(lián)系人:顯示通訊錄中所有聯(lián)系人信息

3:刪除聯(lián)系人:按照姓名進行刪除指定聯(lián)系人

4:查找聯(lián)系人:按照姓名查找聯(lián)系人

5:修改聯(lián)系人:按照姓名修改聯(lián)系人

6:清空聯(lián)系人:按照姓名清空聯(lián)系人

7:退出通訊錄:退出當前使用的通訊錄

2、設(shè)計思路

/**

本教程主要利用C++來實現(xiàn)一個通訊管理系統(tǒng),系統(tǒng)中需要實現(xiàn)如下功能:

1:添加聯(lián)系人:向通訊錄中添加新人(包括:性別,年齡,聯(lián)系電話,家庭住址),并且最多記錄1000人

2:顯示聯(lián)系人:顯示通訊錄中所有聯(lián)系人信息

3:刪除聯(lián)系人:按照姓名進行刪除指定聯(lián)系人

4:查找聯(lián)系人:按照姓名查找聯(lián)系人

5:修改聯(lián)系人:按照姓名修改聯(lián)系人

6:清空聯(lián)系人:按照姓名清空聯(lián)系人

7:退出通訊錄:退出當前使用的通訊錄

//引入C++標準包

#includeiostream

#includestring

//#defineMAX_NUMBER2

usingnamespacestd;

//constintMAX_NUMBER2=3;

//定義常量通訊錄最大值(auto讓編譯其自己推斷變量的類型)

constexprautoMAX=3;

//定義聯(lián)系人結(jié)構(gòu)體

structPerson

stringname;

intsex;

intage;

stringphoneNamer;

stringaddress;

structaddressbook

structPersonperArray[MAX];

//structPersonpersonArr[MAX_NUMBER2];

//structPersonpersonArr[MAX_NUMBER];

intperson_size;

//展示通訊錄系統(tǒng)

voidshowMenu(){

cout"歡迎來到通訊錄管理系統(tǒng)"endl;

cout"功能1:添加聯(lián)系人"endl;

cout"功能2:顯示聯(lián)系人"endl;

cout"功能3:刪除聯(lián)系人"endl;

cout"功能4:查找聯(lián)系人"endl;

cout"功能5:修改聯(lián)系人"endl;

cout"功能6:清空聯(lián)系人"endl;

cout"功能0:退出通訊錄系統(tǒng)"endl;

intisExist(addressbook*personBook,stringname){

for(inti=0;ipersonBook-person_size;i++)

{

if(personBook-perArray[i].name==name)

{

//從通訊錄中找到了某個人

returni;

}

}

return-1;

voidaddPerson(addressbook*addBook){

if(addBook-person_sizeMAX)

{

cout"請輸入姓名:"endl;

stringname;

cinname;

//addBook操作指針指向的哪個對象

addBook-perArray[addBook-person_size].name=name;

cout"請輸入性別對應(yīng)的序號:1--男

2---女"endl;

intsex;

//通過while死循環(huán)持續(xù)性的讀取用戶輸入的性別

while(true){

cinsex;

if((sex==1)||(sex==2))

{

addBook-perArray[addBook-person_size].sex=sex;

break;

}

else

{

cout"您輸入的信息有誤,請重新出入"endl;

}

}

intage=0;

cout"請輸入年齡"endl;

cinage;

addBook-perArray[addBook-person_size].age=age;

stringnamuber;

cout"請輸入電話號碼:"endl;

cinnamuber;

addBook-perArray[addBook-person_size].phoneNamer=namuber;

stringaddress;

cout"請輸入地址"endl;

cinaddress;

addBook-perArray[addBook-person_size].address=address;

//聯(lián)系人添加成功

addBook-person_size++;

cout"聯(lián)系人已成功添加到通訊錄"endl;

}

else

{

cout"通訊錄聯(lián)系人已滿,請刪除部分聯(lián)系人再添加!"endl;

}

system("pause");

system("cls");

//顯示聯(lián)系人

voidshowPerson(addressbookperson){

if(person.person_size==0){

cout"您的通訊錄列表為空"endl;

}

else

{

for(inti=0;iperson.person_size;i++)

{

cout"序號:"i+1":"

"姓名:"person.perArray[i].name":"

"性別:"person.perArray[i].sex":"

"年齡:"person.perArray[i].age":"

"電話:"person.perArray[i].phoneNamer":"

"住址:"person.perArray[i].address""

endl;

}

}

system("pause");

system("cls");

//刪除聯(lián)系人

voiddeletePerson(addressbook*person){

stringname;

cout"請輸入您要刪除的聯(lián)系人姓名:"endl;

cinname;

intisExis=isExist(person,name);

if(isExis!=-1)

{

for(inti=isExis;iperson-person_size;i++)

{

person-perArray[i]=person-perArray[i+1];

}

person-person_size--;

cout"刪除成功"endl;

}

else

{

cout"對不起,通訊錄沒有此人"endl;

}

system("pause");

system("cls");

//查找聯(lián)系人

voidfindPerson(addressbook*address){

stringname;

cout"請輸入您想要查找的聯(lián)系人"endl;

cinname;

intexist=isExist(address,name);

if(exist!=-1)

{

cout"該聯(lián)系人信息如下:"endl;

cout"姓名:"address-perArray[exist].name"

"

"性別:"address-perArray[exist].sex"

"

"年齡:"address-perArray[exist].age"

"

"電話:"address-perArray[exist].phoneNamer"

"

"住址:"address-perArray[exist].address"

"endl;

}

else

{

cout"查無此人喔!"endl;

}

system("pause");

system("cls");

voidmodifyPerson(addressbook*person){

stringmodifyName;

cout"請輸入修改后的姓名:"endl;

cinmodifyName;

intexist=isExist(person,modifyName);

if(exist!=-1)

{

person-perArray[exist].name=modifyName;

while(true)

{

intmodifySex;

cout"請輸入修改后的性別:(1:男

2:女)"endl;

cinmodifySex;

if(modifySex==1||modifySex==2)

{

person-perArray[exist].sex=modifySex;

break;

}

else

{

cout"您應(yīng)當輸入1或者2,請重新輸入"endl;

}

}

intmodifyAge;

cout"請輸入修改后的年齡:";

cinmodifyAge;

person-perArray[exist].age=modifyAge;

stringmodifyPhoneNum;

cout"請輸入修改后的電話:";

cinmodifyPhoneNum;

person-perArray[exist].phoneNamer=modifyPhoneNum;

stringmodifyAddress;

cout"請輸入修改后的地址:";

cinmodifyAddress;

person-perArray[exist].address=modifyAddress;

cout"修改成功!"endl;

}

else

{

cout"查無此人,故無法修改"endl;

}

system("pause");

system("cls");

//清空通訊錄

voidclearPersonAddress(addressbook*personBook){

stringensure;

cout"您確定要是清空所有聯(lián)系人信息嗎?注意此操作不可逆,請謹慎操作,請輸入\"我同意\""endl;

cinensure;

if(ensure=="我同意")

{

personBook-person_size=0;

for(inti=0;ipersonBook-person_size;i++)

{

personBook-perArray[i].address="";

personBook-perArray[i].name="";

personBook-perArray[i].phoneNamer="";

personBook-perArray[i].age=0;

personBook-perArray[i].sex=0;

}

cout"已成功清空通訊錄列表"endl;

}

else

{

cout"撤銷清空聯(lián)系人列表"endl;

}

system("pause");

system("cls");

intmain()

std::cout"通許錄管理系統(tǒng)\n";

structaddressbookaddress;

address.person_size=0;

intuserSelect=-1;

while(true)

{

showMenu();

cout"請在下方輸入您向選擇的功能(輸入下面數(shù)字即可)"

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論