Linux下的C語言程式設計 鍊錶實現通訊錄

2021-07-24 13:10:36 字數 2442 閱讀 4936

用鍊錶實現簡單的通訊錄

#include #include #include #define n 15

struct contact// 瀹氫箟緇撴瀯浣?;

typedef struct contact contact;

typedef struct contact *link;

void creat_list(link *head)//鍒涘緩閾捐〃

(*head)->next = null;

}int len_list(link *head)//璁$畻閾捐〃闀垮害

return len;

}void input(link p)//杈撳靉鑺傜偣煉?

void output(link p)//杈撳嚭鑺傜偣煉?

void insert_tail(link *head)//灝炬彃娉曞緩絝嬮摼琛?

input(p);

while(temp->next != null)

p->next = null;

temp->next = p; }}

void display(link head)//閬嶅巻閾捐〃

while(temp != null) }

void find_name(link head)//鐫夊鍚嶆煡鎵?

while(temp != null)

temp = temp->next;

} if(i == 0) }

void find_number(link head)//鐫夊佛鐮佹煡鎵?

while(temp != null)

temp = temp->next;

} if(i == 0) }

void find_qq(link head)//鐫塹q鍙鋒煡鎵?

while(temp != null)

temp = temp->next;

} if(i == 0) }

void find_addr(link head)//鐫夊湴鍧€鏌ユ壘

while(temp != null)

temp = temp->next;

} if(i == 0) }

void search_node(link head)//鏌ユ壘鍑芥暟

else

}break;

case 2:

find_number(head);

while(1)

else

}break;

case 3:

find_qq(head);

while(1)

else

}break;

case 4:

find_addr(head);

while(1)

else

}break;

default:

break; }}

void delete_node(link *head)//鍒犻櫎鍑芥暟

temp = temp->next;

} temp = (*head)->next;

if(i == 0)

else if(i == 1)

if(strcmp(temp->name,str) == 0)

}else

if(strcmp(temp->number,str1) == 0)

}// len_list(head);

}void alter_name(link p)//淇敼濮撳悕

void alter_***(link p)// 淇敼鎬у埆

void alter_number(link p)//淇敼鍙風爜

void alter_qq(link p)// 淇敼qq

void alter_addr(link p)// 淇敼鍦板潃

void atler(link head)// 淇敼鍑芥暟

if(strcmp(temp->name,str) == 0) }

}void clear(link *head)// 娓呯┖閾捐〃

(*head)->next = null;

}int main()

else

}break;

case 5:

insert_tail(&head);

while(1)

else

}break;

case 6:

atler(head);

while(1)

else

}break;

case 7:

clear(&head);

break;

case 0:

exit(0);

break;

default:

printf("input error!\n");

break;

} }return 0;

}

Linux下的C語言程式設計 雙向迴圈鍊錶的簡單實現

下面我先貼上我的 include include struct node typedef struct node dbnode typedef struct node dblink void creat link dblink head 建立鍊錶 head next head prior head ...

C 鍊錶 實操

一 鍊錶的基礎操作 1.定義乙個鍊錶 struct listnode 2.建立乙個基礎鍊錶 長度為n listnode create normal list int n end next null 尾節點最後指向乙個新的空位址 head last null 頭節點的前一位不存在 return hea...

Linux下C語言程式設計

include include include include define max 10pthread t thread 2 pthread mutex t mut int number 0 i void thread1 printf thread1 主函式在等我完成任務嗎?n pthread e...