簡單的通訊錄

2021-08-01 23:42:45 字數 4057 閱讀 2374

#include

#include

#include

#define t 1

#define f -1

typedef int status;

typedef char type_nam;

typedef char type_num;

typedef char type_add;

struct list

;type_nam *name_1 = ;

type_num *number_1 = ;

type_add *address_1 = ;

type_nam *name_2 = ;

type_num *number_2 = ;

type_add *address_2 = ;

status init (struct list** head);

status insert(struct list *head, type_nam *name_2, type_num *number_2, type_add *address_2, int count_2);

status delete_cou(struct list *head, int count_2);

status delete_num(struct list *head, type_num *number_2);

status delete_nam(struct list *head, type_nam *name_2);

status update_cou(struct list *head, type_nam *name_3, type_num *number_3, type_add *address_3, int count_3);

status update_nam(struct list *head, type_nam *name_3, type_num *number_3, type_add *address_3, type_nam *name_4);

status update_num(struct list *head, type_nam *name_3, type_num *number_3, type_add *address_3, type_num *number_4);

status query_cou(struct list *head, int count_5);

status query_nam(struct list *head, type_nam *name_5);

status query_num(struct list *head, type_num *number_5);

status sort_num(struct list *head);

status sort_nam(struct list *head);

void print(struct list *head);

int main()

if(t == ret)

int i;

for(i = 0; i < 4; i++)

print(head);

//delete_cou(head, 3); 

//printf("****按編號刪除******************************************\n");

//print(head);

//delete_num(head, number_1[1]);

//printf("****按號碼刪除******************************************\n");

//print(head);

//delete_nam(head, name_1[2]);

//printf("****按名字刪除******************************************\n");

//print(head);

// update_cou(head, name_2[0], number_2[0], address_2[0], 3); 

// printf("****按編號替換******************************************\n");

// print(head);

//update_nam(head, name_2[0], number_2[0], address_2[0], name_1[2]);

//printf("****按名字替換******************************************\n");

//print(head);

//update_num(head, name_2[0], number_2[0], address_2[0], number_1[2]);

//printf("****按號碼替換******************************************\n");

//print(head);

//printf("****按編號查詢******************************************\n");

//query_cou(head, 3);

//printf("****按名字查詢******************************************\n");

//query_nam(head, name_1[2]);

//printf("****按號碼查詢******************************************\n");

//query_num(head, number_1[2]);

//printf("****按號碼排序******************************************\n");

//sort_num(head);

//print(head);

printf("****按名字排序******************************************\n");

sort_nam(head);

print(head);

}status init (struct list** head)

newlist->next = null;

*head = newlist;

return t;

}status insert(struct list *head, type_nam *name_2, type_num *number_2, type_add *address_2, int count_2)

strcpy(newlist->name, name_2);

strcpy(newlist->number,  number_2);

strcpy(newlist->address, address_2);

newlist->count = count_2;

newlist->next = null;

while(head->next != null)

head->next = newlist;

return t;

}status delete_cou(struct list *head, int count_2)

}struct list *temp;

temp = head->next->next;

free(head->next);

head->next = temp;

}status delete_num(struct list *head, type_num *number_2)

if(strcmp((head->next->number) ,( p->next->number)) > 0 )

}head = head->next;} }

status sort_nam(struct list *head)

struct list *p;

for(i = 0; null != head->next; i++)

{    

p = head;

for(j = 0;j < 4 - i; j++)

{    

p = p->next;

if(null == p->next)

{continue;

通訊錄簡單實現

姓名 性別 年齡 住址 利用構建乙個結構體來儲存資訊,結構體的大小根據所需來自行規定 typedef struct add add typedef struct addnode addnode 關於資訊儲存的方法,最簡單的兩種辦法就是鍊錶跟順序表的結構,簡單說呢就是兩種不同的對資料或者說結構體的應用...

Linux C 簡單通訊錄

通訊錄專案 結構體陣列 1.使用結構體來存放資料,使用陣列來存放結構體 2.struct data 3.知識點 資料型別 陣列結構體 語句 for switch if break return 函式 盡可能的都用函式去寫,可以先都在main函式裡實現,最後改寫為函式 字串函式 strcpy strc...

簡單的TableView通訊錄

先定義了兩個viewcontroller 乙個用來寫通訊錄的介面 乙個顯示詳細資訊 定義了student類 student.h 定義屬性 初始化方法 便立構造器 property nonatomic,retain nsstring name property nonatomic,assign nsi...