數(shù)據(jù)庫設(shè)計作業(yè)_第1頁
數(shù)據(jù)庫設(shè)計作業(yè)_第2頁
數(shù)據(jù)庫設(shè)計作業(yè)_第3頁
數(shù)據(jù)庫設(shè)計作業(yè)_第4頁
數(shù)據(jù)庫設(shè)計作業(yè)_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

數(shù)據(jù)庫設(shè)計:班級通訊錄

一.班級通訊錄程序設(shè)計(C語言):#include<conio、h>

#include<stdio>h>

include<iostream>

#include<string>

include<iomanip>

include<fstream>

include<cstdlib>

usingnamespacestd;

classbook

(

public:

book();〃默認構(gòu)造函數(shù)

charinter_face();〃首頁

voidadd_person();〃添力口聯(lián)系人

voiddel_person();〃刪除聯(lián)系人

voidshow_all();〃顯示所有聯(lián)系人

voidalter();〃修改信息

voidselect();〃查詢聯(lián)系人

voidsave_new();〃保存新增加的聯(lián)系人

private:

stringname;〃姓名

stringaddress;〃地址

stringnumber;〃電話號碼

stringpost;〃郵編

stringqq;//QQ號

);

structrecord

(

bookobject;〃雙向鏈表中的數(shù)據(jù)域就是就是一個記錄類

record*prior;〃指向前軀

record*next;〃指向后繼

);

book::book()

{

name="\0";

address="\0";

number="\0";

post="\0";

qq="\0";

)

〃首頁

charbook::inter_face()

(

system("cls");

cout?endl;

※“?endl

班級通迅錄※“?endl

〈〈"'NX※“?endl

〈〈"'NX1、添加新聯(lián)系人、4、修改信息、※“?endl

※“?endl

〈〈"'NX2、刪除聯(lián)系人、5、查詢聯(lián)系人、?endl

〈〈"'NX※“?endl

〈〈"'NX3、顯示所有聯(lián)系人、6、關(guān)閉通迅錄、※“?endl

※“?endl

?endl?endl

選擇

charchoose;

cin?choose;

fflush(stdin);

returnchoose;

)

〃添加聯(lián)系人

voidbook::add_person()

(

cout<vendlvv"根據(jù)下面提示輸入新聯(lián)系人信息"?endl?endl

姓名:";

cin?name;

fflush(stdin);

coutvv"電話:”;

cin?number;

fflush(stdin);

cout?"QQ:

cin?qq;

fflush(stdin);

coutvv”郵編:”;

cin?post;

fflush(stdin);

cout<<"地址:

cin?address;

fflush(stdin);

save_new();

cout?endl?endl<<“新聯(lián)系人信息已經(jīng)保存好!!!!!"?endl?endl;

system("pause");

}

〃刪除聯(lián)系人

voidbook::del_person()

(

ofstreamoutData("temp>txt",ios::out);

ifstreaminData("pbook>txt",ios::in);

if(loutData11iinData)

(

cout<<endl<<”對不起!!!!找不到文件!!!!”?endl;

system("pause");

return;

)

stringsign;

cout<<endl<<"您要刪除輸入姓名或電話號:";

cin?sign;

stringstrl;

boolflag=true;

stringstr;

while(inData?name?number)

(

getlinefinData,str);

if((sign==name)11(sign==number))

(

cout?endl<<"您想刪除的聯(lián)系人:"?endl?endl;

cout?strl?endl;

cout?setiosflags(ios::left)?setw(17)?name

?""?number?str?endl;

flag=false;

break;

}

outData?setiosflags(ios::left)?setw(17)?name

?""?number?str?endl;

}

if(flag)

(

cout<<endl<v"對不起!!!聯(lián)系人中沒您找的人!!!!”?endl?endl;

)

else

(

while(getline(inData,str))

(

outData?str?endl;

}

outData>close();

inData、close();

ofstreamout("pbook>txt",ios::out);

ifstreamin("temp>txt",ios::in);

if(lout11!in)

(

cout?endl對不起不能打開文件!!!"?endl?endl;

system("pause");

return;

}

while(getline(in,str))

(

out?str?endl;

}

out、close();

in、close();

cout<<endlvv"這個人的信息已經(jīng)從您的通迅錄中刪除!!!"?endl?endl;

}

system("pause");

}

〃顯示所有聯(lián)系人

voidbook::show_all()

(

ifstreaminData("pbook>txf'Jos-in);

if(linData)

(

cout<<endl<<"對不起!!!!沒有找到文件!!!!!”?endl;

system("pause");

return;

}

boolflag=true;

stringrecord;

while(getline(inData,record))

(

if(flag)

(

cout<<endl<<”所有聯(lián)系人信息如下:"?endl;

}

cout?record?endl;

flag=false;

}

if(flag)

(

cout<vendl您的通迅錄中沒有聯(lián)系人!!!!!”?endl?endl;

}

else

cout<vendl<v"所有聯(lián)系人已經(jīng)全部顯示出來!!!!!"?endl?endl;

)

system("pause");

)

〃修改信息

voidbook::alter()

(

ifstreaminData("pbook>txt",ios::in);

if(linData)

(

cout<vendl對不起不能打開文件!!!!!”?endl?endl;

system("pause");

return;

}

stringsign;

cout?endl<<“請輸入您想要修改的聯(lián)系人的姓名或電話號碼:";

cin?sign;

fflush(stdin);

stringstrl;

getlinefinData,strl);

record*H=newrecord;

record*p=H;

record*q=H;

boolflag=true;

while(inData?p->object>name?p->object>number?p->object>qq

?p->object>post?p->object>address)

(

p->next=newrecord;

p=p->next;

p->prior=q;

q->next=p;

q=p;

)

p->next=NULL;

inData、close();

P=H;

while(p)

(

if((p->object>name==sign)11(p>>object>number二二sign))

(

if(flag)

cout<<endl<<"您想修改您聯(lián)系人的信息如下:"?endl?endl;

cout?endl?strl?endl;

cout?setiosflags(ios::left)?setw(17)

<<p->object、name?""?setw(16)?p->object>number

?""?setw(18)?p->object>qq

?""?setw(14)?p->object>post

?""?setw(20)?p->object>address?endl;

flag=false;

)

cout?endl請根據(jù)下面提示修改信息:"?endl;

coutvv“姓名:”;

cin?p->object>name;

fflush(stdin);

cout?"電話號:";

cin?p->object>number;

fflush(stdin);

cout?"QQ

cin?p->object>qq;

fflush(stdin);

coutvv"郵編

cin?p->object>post;

fflush(stdin);

cout?”地址

cin?p->object>address;

fflush(stdin);

break;

}

p=p->next;

)

if(flag)

(

cout<<endl<<"您的通迅錄中沒有您找的聯(lián)系人!!!!"?endl?endl;

system("pause");

return;

)

else

(

ofstreamout("pbook>txt"zios::out);

if(lout)

(

cout<<endl對不起!!!不能打開文件!!!!”?endl;

system("pause");

return;

)

out?strl?endl;

p=H->next;

while(p)

out?setiosflags(ios::left)?setw(17)?p->object>name

?""?setw(16)?p->object>number

?""?setw(18)?p->object>qq

?""?setw(14)?p->object>post

?""?setw(20)?p->object>address?endl;

p=p->next;

)

out、close();

coutvvendl信息已經(jīng)修改完成!!!!"?endl?endl;

system("pause");

}

}

〃查詢聯(lián)系人

voidbook::select()

(

ifstreaminData("pbook>txt”,ios::in);

if(linData)

(

cout<<endl<<"對不起!!!!文件找不到!!!!”?endl;

system("pause");

return;

)

stringsign;

cout<<endl<(“輸入您想查找的聯(lián)系人的姓名或電話號碼:

cin?sign;

fflush(stdin);

stringstrl;

boolflag=true;

stringstr;

while(inData?name?number)

{

getlinefinData,str);

if((name==sign)11(number==sign))

(

cout?endl<<“您要查找的聯(lián)系人就是:"?endl?endl;

cout?strl?endl;

cout?setiosflags(ios::left)?setw(17)?name

?number?str?endl;

flag=false;

break;

)

)

)

voidbook::save_new()

(

ofstreamoutData("pbook>txt",ios::app);

if(loutData)

(

cout<<endl<<”對不起!!!打開文件失敗!!!!”?endl?endl;

system("pause");

return;

)

outData?setiosflags(ios::left)?setw(17)?name

?""?setw(16)?number?""

?setw(18)?qq?""

?setw(14)?post?""

?setw(20)?address?endl;

outData>close();

)

enumpower{ADD='1',DEL='2;SHOW='3',Alter='4',Select='5',END='6'};

intmain()

(

charch

溫馨提示

  • 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

提交評論