C語言 用鍊錶實現電話本的功能

2021-07-05 18:04:55 字數 1849 閱讀 4812

簡介:

用鍊錶實現**本的功能(c語言)

**本具有如下4個功能:

1.建立乙個**本,**本裡面包含名字和**號碼

2.在指定位置插入乙個名字和**號碼

3.在指定位置刪除乙個名字和**號碼

4.列印**本

//其中那個color函式是我為了美觀加上去的,如果感覺不需要的話可以將**中所有有關color的都刪掉即可

#include 

#include

#include

#include

#include

using

namespace

std;

const

int n = 1000+10;

int n;

struct list

};struct list *root = new

struct list;

void creat();

void delet();

void add();

void print();

void color(const

unsigned

short color1);

int main()

printf("\n now,you can enter an optiton:");

}return0;}

void creat()

struct list *cur = root;

for(int i=1;i<=n;i++)

color(9);

cout

<<" well done,the phonetxt has been created!!!"

<14);

return;

}void delet()

struct list *cur = root;

if(x==1)

else

}n--;

color(9);

cout

<<" well done,the member has been deleted!!!"

<14);

return;

}void add()

char name[100],number[20];

printf(" input the person name:");

scanf(" %s",name);

printf(" input the person phonenumber:");

scanf(" %s",number);

struct list *cur = root;

if(x==1)

else

else

}n++;

color(9);

cout

<<" well done,the member has been added!!!"

<14);

return;

}void print()

printf(" %s %s\n",cur->name,cur->number);

color(14);

color(9);

cout

<<" well done,the phonetxt is above!!!"

<14);

return;

}void color(const

unsigned

short color1)

雜湊表的應用之電話本

include include include include using namespace std struct phone 初始化為空 class myphone bool find string a,int ranks for int i 0 i s int pos s.find 0 判斷有...

順序表的應用 電話本

順序表 就所謂的陣列式操作 程式設計實現順序儲存結構中的基本操作的實現 本的建立 插入 刪除 修改 逆置 查詢 輸出 整個操作過於簡陋,只對上述功能做敘述,採用結構體陣列實現,本打算用class操作,可因為某種原因就擱置了 中的注釋部分是用於測試資料,本只存有number,name size全域性變...

用結構體實現乙個電話本

結構體是c語言又乙個儲存資料的型別,那麼用結構體怎麼實現乙個簡單的可以儲存1000個人資訊的 本呢?一.首先需要定義乙個結構體,包含乙個人的資訊 比如姓名,性別,年齡,住址等等 我們先來定義乙個結構體。typedef struct pdhb info pdhb info 二.需要儲存1000個人的資...