91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

c++課程設(shè)計(jì)中的通訊錄,詳看博客http://blog.csdn.net/mybelief321

資源截圖

代碼片段和文件信息

/*TelBook.cpp*/
#include
#include
#include
#include

using?namespace?std;
string?ID;//字符串類ID全局變量,具有唯一性

class?Person?//定義人類
{
protected:
string?StuId;//學(xué)號(hào)
string?Age;?//年齡
char?Name[20];?//姓名
char?Sex[10];?//性別
string?Tel;??//電話
Person?*next;?//Person類對(duì)象指針變量
public:
Person(string?IDchar?*Namechar?*Sexstring?Age?string?Tel)
{
strcpy(this->NameName);
strcpy(this->SexSex);
this->Tel=Tel;
this->StuId=ID;
this->Age=Age;
}

friend?class?Manage;//友元類
/*Manage類是Person類的友元類,則Manage類的所有成員函數(shù)都是Person
類的友元函數(shù),都可以訪問(wèn)Person類的私有和保護(hù)成員*/
};

class?Manage??//管理?類
{
public:
Manage()??//構(gòu)造函數(shù)
{
person=0;
Load();??//成員函數(shù)
}
~Manage()??//析構(gòu)函數(shù)
{
Person?*p;//Person類的對(duì)象指針變量
p=person;
while(p)?//當(dāng)p不為0,即電話簿中記錄不為0
{
p=p->next;
delete?person;?//刪除該類對(duì)象
person=p;//準(zhǔn)備刪除下一對(duì)象
}
person=0;
}

void?Find(char?Name[20]);//按姓名查找
void?Find(string?ID);?//按學(xué)號(hào)查找
void?Add();?//添加信息
void?Delete();//刪除信息
void?Modify(string?ID);//修改信息
void?Query();?//查詢信息
void?TJ();?//清除文件信息
void?Save();//保存數(shù)據(jù)
void?Load();//讀入數(shù)據(jù)
void?Look();//預(yù)覽
void?DesTory();//
void?Output(Person?*p)
{
cout<<“\t\t學(xué)號(hào):?“<StuId< cout<<“\t\t姓名:?“<Name< cout<<“\t\t性別:?“<Sex< cout<<“\t\t年齡:?“<Age< cout<<“\t\t電話:?“<Tel< cout<
}
private:
Person?*person;?//Person類對(duì)象指針
};
void?Manage::Add()
{
system(“clear“);//清屏命令Windows對(duì)應(yīng)的是cls
Person?*p*p2;?//新節(jié)點(diǎn)指針
string?StuIdAgeTel;
char?Name[20]Sex[10];
char?c;
cout<<“\n**?新增學(xué)生通訊錄?**\n“;
//輸入學(xué)生信息
cout<<“輸入學(xué)號(hào):\t“;
cin>>StuId;
cout< {//塊作用域
Person?*p1;
p1=person;
while(p1)
{
if(p1->StuId==StuId)
{
break;
}
else
{
p1=p1->next;
}
}
if(p1!=NULL)
{
cout<<“該學(xué)號(hào)已存在,是否修改學(xué)生信息(Y/N):“< cin>>c;
if(toupper(c)==‘Y‘)?//touper()函數(shù)是將字符轉(zhuǎn)換為對(duì)應(yīng)的大寫(xiě)字母
{
cout<<“該學(xué)生信息為:?“< Find(StuId);
cout< Modify(StuId);
return?;
}
else
return?;
}
}//塊作用域
cout<<“輸入姓名:\t“;
cin>>Name;
cout<
cout<<“輸入性別:\t“;
cin>>Sex;
cout<
cout<<“輸入年齡:\t“;
cin>>Age;
cout<
cout<<“輸入電話:\t“;
cin>>Tel;
cout<
p=new?Person(StuIdNameSexAgeTel);
p->next=0;
//學(xué)生節(jié)點(diǎn)加入鏈表
??? if(person)??//若已經(jīng)存在節(jié)點(diǎn)
{
p2=person;
while(p2->next)?//查找尾節(jié)點(diǎn)
{
p2=p2->next;
}
p2->next=p;?//連接
}
else?//若不存在節(jié)點(diǎn)(表空)
{
person=p;?//連接
}
system(“clear“);
cout<<“\t\t\t?****添加成功***\n“< cout<<“是否繼續(xù)添加?(Y/N)“< cin>>c;
if(toupper(c)==‘Y‘)
{
Add();
return?;
}
else
return;
}

void?Manage::Delete()??//刪除人員
{
system(“clear“);
char?c;
char?ch;
string?StuId;
cout<<“\n**?刪除信息?**\n“;
cout<<“輸入要?jiǎng)h除的學(xué)生ID:\t“;
cin>>StuId;
cout< //查找要?jiǎng)h除的節(jié)點(diǎn)
Person?*p1*p2;
p1=person;
while(p1)
{
if(p1->StuId==StuId)
break;
else
{
p2=p1;
p1=p1->next;
}
}
//刪除節(jié)點(diǎn)
if(p1!=NULL)?//若找到節(jié)點(diǎn),則刪除
{
cout<<“所要?jiǎng)h除的學(xué)生的信息如下:\n“< Output(p1);
cout<<“確定是否刪除(Y/N):?“;
cin>>c;
if(toupper(c)!=‘Y‘)
return;
if(p1==

評(píng)論

共有 條評(píng)論