C 通訊錄設計 鍊錶實現

2021-10-10 18:03:10 字數 3673 閱讀 6710

1新增學生資訊

2刪除學生資訊

3顯示學生資訊

4查詢學生資訊

5學生資訊排序

6清空螢幕資訊

7清空文件資訊

8退出管理系統

上**!

#include 

#include

#include

#include

//讀寫檔案的標頭檔案

using namespace std;

struct elementtype;

struct node;

struct queue;

typedef struct queue* myqueue;

struct elementtype

;struct node

;struct queue

;myqueue init

(myqueue& q)

;//initialize queue

bool isempty

(myqueue q)

;//determine if the queue is empty

bool insert

(elementtype x, myqueue q)

;//insert the data to the end of the queue

bool delete

(const int message, myqueue q)

;//find some data in the queue, and then delete the corresponding node

void

print

(const node* q)

;//prints all the information in a node

void

printall

(const myqueue q)

;//prints information from all nodes

bool findbyname

(const string massage,

const myqueue q)

;//prints information from all nodes

void

input

(myqueue q)

;//when the address book is empty, re-enter the information into the address book

void

write

(myqueue q)

;//write the information from the queue to the document

myqueue read()

;//write the information from the queue to the document

myqueue readorclear

(myqueue& q)

;//whether to empty all the information

void

swap

(elementtype& x, elementtype& y)

;//swap functions in sort

myqueue bubblesort

(myqueue q)

;//sort by student id using bubble sort

void

menu

(myqueue q)

;//main menu

//初始化佇列

myqueue init

(myqueue& q)

//檢視佇列是否為空

bool isempty

(myqueue q)

//新增資訊

bool insert

(elementtype x, myqueue q)

else

}//刪除功能

bool delete

(const int message, myqueue q)

else

if(q-

>rear-

>data.id == message)

else

if(pd ==1)

}//通過姓名進行查詢

bool findbyname

(const string massage,

const myqueue q)

else

}//單個進行列印

void

print

(const node* q)

//列印全部的學生資訊

void

printall

(const myqueue q)

cout <<

"姓名"

;for

(int i =

0; i <

10; i++

) cout <<

"**號碼"

<< endl;

node* temp;

temp = q-

>front;

while

(temp !=

null

)//cout << endl;

}//實現排序的功能函式

void

swap

(elementtype& x, elementtype& y)

myqueue bubblesort

(myqueue q)}}

return q;

}//把全部資訊存入到文件中

void

write

(myqueue q)

node* temp =

newnode()

;if(q!=

null)}

writeit.

close()

;}//從文件中讀出所有的資訊

myqueue read()

int id1;

string name1;

int num1;

myqueue q=

newqueue()

; elementtype x;

while

(!readit.

eof())

readit.

close()

;return q;

}//讀入文件中的資訊

myqueue readorclear

(myqueue& q)

//使整個佇列置空

void

makeempty

(myqueue& q)

}//主選單

void

menu

(myqueue q)

case2:

;break;}

case3:

case4:

break;}

case5:

case6:

case7:

break;}

case8:

default

: cout <<

"輸入的選項序號有誤,請重新輸入!"

<< endl;}}

}int main()

鍊錶通訊錄

include include include define password 208140119 define name max 20 define gender max 10 define str max 20 define tel max 20 鍊錶結構 struct address type...

鍊錶通訊錄

include include include include include struct addressbook typedef struct addressbook addressbook typedef struct addressbook link int main menu void a...

利用鍊錶實現通訊錄

用鍊錶實現乙個 可以用來儲存資訊的通訊錄,每個人的資訊包括 姓名 性別 年齡 住址 程式如下 include include include define len sizeof struct student struct student void menu 目錄格式 struct student c...