鍊錶實現電話簿(C )

2021-10-03 16:40:40 字數 2559 閱讀 2292

//試驗3 **簿管理系統

//鍊錶實現

#include

#include

#include

#include

#include

#include

#include

//獲取當前時間

#define name_size 20

#define number_size 12

using

namespace std;

//鍊錶結構

struct message

;//鍊錶節點

typedef

struct nodenode;

//**簿類

class

tele_book

intadd_tele()

;//新增

intfind_tele()

;int

delete_tele()

;void

show_tele()

;~tele_book()

}};//增加記錄 按字母順序插入

int tele_book::

add_tele()

//將指向下一節點位置設為null

new_tele-

>next =

null

;//eatline

while

(getchar()

!='\n'

)continue

; cout<<

"姓名:"

; cin.

getline

(new_tele-

>tele_message.tele_name,name_size);

current_tele =

*temp_linkp;

while

(current_tele !=

null

&&strcmp

(current_tele-

>tele_message.tele_name,new_tele-

>tele_message.tele_name)==-

1)//傳遞值,輸入值

cout<<

"**號碼:"

; cin>>new_tele-

>tele_message.tele_number;

//當前時間

time_t time_now =

time(0

);strftime

(new_tele-

>tele_message.tele_time,

sizeof

(new_tele-

>tele_message.tele_time)

,"%y/%m/%d %x %a"

,localtime

(&time_now));

//時間格式

new_tele-

>next = current_tele;

*temp_linkp = new_tele;

cout<<

"建立成功\n"

;return

true;}

//查詢記錄

int tele_book::

find_tele()

if(current ==

null

)else

}else

if(chioce ==

'2')

temp_linkp =

¤t->next;

current =

*temp_linkp;

} cout<<

"按回車鍵返回系統主頁面"

; cout

;getchar()

;return

true;}

else

cout<<

"tip:已返回\n\n";}

//刪除記錄

int tele_book::

delete_tele()

//沒有找到

if(current-

>next ==

null

&&strcmp

(current-

>tele_message.tele_name, temp_name)!=0

)elseif(

strcmp

(current-

>tele_message.tele_name, temp_name)==0

&& precious ==

null

)else

}//顯示記錄

void tele_book::

show_tele()

cout<<

"顯示完畢\n"

; cout<<

"按回車鍵返回系統主頁面\n"

; cout

;getchar()

;}//主函式

intmain

(void)}

return0;

}

電話簿專案

專案一 簿 有個父類book,有成員變數 書本的名字,書本的路徑,有4個純虛函式,分別是增刪查改。類phonebook繼承了類book,並擴充套件了 號碼,姓名,擴充套件了登陸介面,實現了父類的4個純虛函式。資料資訊使用文字的方式儲存!include using namespace std incl...

Python實現簡單電話簿

時間有限,先上 後續講解馬上來 import time import os import pickle class background user details def write self f open 聯絡人.txt wb pickle.dump background user.details...

python 電話簿排序

問題描述 編寫乙個程式,輸入n個使用者的姓名和 號碼,按照使用者姓名的詞典順序排列輸出使用者的姓名和 號碼。輸入形式 使用者首先在第一行輸入乙個正整數,該正整數表示待排序的使用者數目,然後在下面多行輸入多個使用者的資訊,每行的輸入格式為 姓名 以回車結束每個使用者的輸入。輸出形式 程式輸出排序後的結...