#include#includeusing namespace std;
#define MAX 1000
struct Person
{string m_Name;
string m_Sex;
int m_Age;
string m_Phone;
string m_Address;
};
struct AddressBooks
{struct Person personArray[MAX];
int m_Size;
};
void show_Menu()
{cout<< "****************************"<< endl;
cout<< "***** 1 Add a contact ******"<< endl;
cout<< "***** 2 Show a contact *****"<< endl;
cout<< "***** 3 Delete a contact ***"<< endl;
cout<< "***** 4 Find a contact *****"<< endl;
cout<< "***** 5 Edit a contact *****"<< endl;
cout<< "***** 6 Clear all contact **"<< endl;
cout<< "***** 0 Exit Address book **"<< endl;
cout<< "****************************"<< endl;
}
void Add_Contact(AddressBooks* Adr_B)
{if (Adr_B->m_Size == MAX)
{cout<< "Ops!! Address is full!!"<< endl;
return;
}
else
{string name;
cout<< "Please input name:"<< endl;
cin >>name;
Adr_B->personArray[Adr_B->m_Size].m_Name = name;
cout<< "Please input sex: (1 : women, 2 : man)"<< endl;
while (true)
{int sex = 0;
cin >>sex;
if (sex == 1)
{Adr_B->personArray[Adr_B->m_Size].m_Sex = "woman";
break;
}
else if (sex == 2)
{Adr_B->personArray[Adr_B->m_Size].m_Sex = "man";
break;
}
else
{cout<< "Input error! Please input 1 or 2"<< endl;
}
}
cout<< "Please input age :"<< endl;
while (true)
{int age = 0;
cin >>age;
if (age >0 && age< 110)
{Adr_B->personArray[Adr_B->m_Size].m_Age = age;
break;
}
else
{cout<< "Input error! Please check your input!"<< endl;
}
}
string phone_number;
cout<< "Please input phone_number:"<< endl;
cin >>phone_number;
Adr_B->personArray[Adr_B->m_Size].m_Phone = phone_number;
string Address;
cout<< "Please input Address: "<< endl;
cin >>Address;
Adr_B->personArray[Adr_B->m_Size].m_Address = Address;
Adr_B->m_Size++;
cout<< "Add contact successful!"<< endl;
}
system("pause");
system("cls");
}
void Show_contact(AddressBooks* Adr_B)
{if (Adr_B->m_Size == 0)
{cout<< "AddressBooks is empty!"<< endl;
}
else
{for (int i = 0; i< Adr_B->m_Size; ++i)
{cout<< "Name: "<< Adr_B->personArray[i].m_Name<< "\t"
<< "Sex : "<< Adr_B->personArray[i].m_Sex<< "\t"
<< "Age : "<< Adr_B->personArray[i].m_Age<< "\t"
<< "Phone : "<< Adr_B->personArray[i].m_Phone<< "\t"
<< "Address : "<< Adr_B->personArray[i].m_Address<< endl;
}
}
system("pause");
system("cls");
}
int Exist_check(AddressBooks* Adr_B, string name)
{for (int i = 0; i< Adr_B->m_Size; ++i)
{if (Adr_B->personArray[i].m_Name == name)
{return i;
}
}
return -1;
}
void Delete_contact(AddressBooks* Adr_B)
{cout<< "Please input the contact name to delete :"<< endl;
string name;
cin >>name;
int check_return = Exist_check(Adr_B, name);
if (check_return != -1)
{for (int i = check_return; i< Adr_B->m_Size; ++i)
{Adr_B->personArray[i] = Adr_B->personArray[i + 1];
}
Adr_B->m_Size--;
cout<< "Delete complete!"<< endl;
}
else
{cout<< "This person is not in the address book"<< endl;
}
system("pause");
system("cls");
}
void Find_contact(AddressBooks* Adr_B)
{cout<< "Please input the contact name to search :"<< endl;
string name;
cin >>name;
int check_return = Exist_check(Adr_B, name);
if (check_return != -1)
{cout<< "Name: "<< Adr_B->personArray[check_return].m_Name<< "\t"
<< "Sex : "<< Adr_B->personArray[check_return].m_Sex<< "\t"
<< "Age : "<< Adr_B->personArray[check_return].m_Age<< "\t"
<< "Phone : "<< Adr_B->personArray[check_return].m_Phone<< "\t"
<< "Address : "<< Adr_B->personArray[check_return].m_Address<< endl;
}
else
{cout<< "This person is not in the address book"<< endl;
}
system("pause");
system("cls");
}
void Edit_contact(AddressBooks* Adr_B)
{cout<< "Please input the contact name to Edit :"<< endl;
string name;
cin >>name;
int check_return = Exist_check(Adr_B, name);
if (check_return != -1)
{string name;
cout<< "Please input name:"<< endl;
cin >>name;
Adr_B->personArray[check_return].m_Name = name;
cout<< "Please input sex: (1 : women, 2 : man)"<< endl;
int sex = 0;
while (true)
{cin >>sex;
if (sex == 1)
{Adr_B->personArray[check_return].m_Sex = "woman";
break;
}
else if (sex == 2)
{Adr_B->personArray[check_return].m_Sex = "man";
break;
}
else
{cout<< "Input error! Please input 1 or 2"<< endl;
}
}
cout<< "Please input age :"<< endl;
while (true)
{int age = 0;
cin >>age;
if (age >0 && age< 110)
{Adr_B->personArray[check_return].m_Age = age;
break;
}
else
{cout<< "Input error! Please check your input!"<< endl;
}
}
string phone_number;
cout<< "Please input phone_number:"<< endl;
cin >>phone_number;
Adr_B->personArray[check_return].m_Phone = phone_number;
string Address;
cout<< "Please input Address: "<< endl;
cin >>Address;
cout<< "Edit contact successful!"<< endl;
}
else
{cout<< "This person is not in the address book"<< endl;
}
system("pause");
system("cls");
}
void Clear_contact(AddressBooks* Adr_B)
{cout<< "Please confirm again whether to clear the address book!!"<< endl;
cout<< "Clear ------ 1"<< endl;
cout<< "Cancel------ 2"<< endl;
int Clear_check = 0;
cin >>Clear_check;
if (Clear_check == 1)
{Adr_B->m_Size = 0;
cout<< "Address book cleared"<< endl;
}
system("pause");
system("cls");
}
int main()
{AddressBooks Adr_B;
int select = 0;
Adr_B.m_Size = 0;
while (true)
{show_Menu();
cin >>select;
switch (select)
{case 1: // add contact
Add_Contact(&Adr_B);
break;
case 2: // show contact
Show_contact(&Adr_B);
break;
case 3: // delete contact
Delete_contact(&Adr_B);
break;
case 4: // find contact
Find_contact(&Adr_B);
break;
case 5: //edit contact
Edit_contact(&Adr_B);
break;
case 6: //clear contact
Clear_contact(&Adr_B);
break;
case 0: // exit system
cout<< "Thanks for using Address book management system"<< endl;
return 0;
break;
default:
break;
}
}
return 0;
}
功能展示
1、初始界面展示我們注重客戶提出的每個(gè)要求,我們充分考慮每一個(gè)細(xì)節(jié),我們積極的做好網(wǎng)站制作、成都網(wǎng)站建設(shè)服務(wù),我們努力開拓更好的視野,通過不懈的努力,創(chuàng)新互聯(lián)贏得了業(yè)內(nèi)的良好聲譽(yù),這一切,也不斷的激勵(lì)著我們更好的服務(wù)客戶。 主要業(yè)務(wù):網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)站設(shè)計(jì),重慶小程序開發(fā),網(wǎng)站開發(fā),技術(shù)開發(fā)實(shí)力,DIV+CSS,PHP及ASP,ASP.Net,SQL數(shù)據(jù)庫的技術(shù)開發(fā)工程師。2、添加一定數(shù)量的聯(lián)系人信息,包括(姓名、性別、年齡、電話、住址);2、展示通訊錄中所有聯(lián)系人信息;3、刪除指定聯(lián)系人;
3.1 無聯(lián)系人返回錯(cuò)誤信息3.2 有聯(lián)系人進(jìn)行刪除操作,提示成功信息;你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購,新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧