資源簡介
【附源代碼】
現在最低分只能設置2分,想0分分享給大家的,官方取消了0分分享,連1分都沒有了,很無奈!!!!
很簡單的鏈表了,包含有新建學生信息、查看學生信息、刪除、修改、清空等功能。
說實話,不值2分。代碼也分享在我博客上面了,可以直接查看:
http://blog.csdn.net/wu9797/article/details/77606258
代碼片段和文件信息
/*====學生信息管理系統--基于單向鏈表結構============*/
/*?
*版本1.3-20170826:========單鏈表========
*在上一個版本基礎上,增加了查找、修改、清空、刪除功能
*發現的未解決的小BUG:
*/
#include?
#include?
#include?
#include?
//0.設計節點
typedef?struct?student
{
char?id[20];???//學號
char?name[20];?//姓名
int?age;???//年齡
char?nu[13];??//電話
float?score;??//成績
struct?student?*next;??//指針
}list_stu?*ptr_stu;
//函數的聲明
ptr_stu?init_list(void);?//初始化
ptr_stu?creat_node(void);?//創建節點
void?interface(void);?//主界面
void?insert_node(ptr_stu?head?ptr_stu?new);?//插入新結點
void?display_node(ptr_stu?head);?//顯示鏈表
void?choice(ptr_stu?head);?//選擇相應的功能
void?delete_node(ptr_stu?head?char?id_input[]);?//刪除節點
void?modify_node(ptr_stu?head?char?id_input[]);?//更改信息
bool?is_empty(ptr_stu?head);?//判斷空表
void?clear_list(ptr_stu?head);?//清空鏈表
void?find_node(ptr_stu?head?char?id_input[]);?//查找節點?
int?main(int?argc?char?*argv[])
{
printf(“\n\t\t\033[1;32m學生信息管理系統\033[0;0m\n“);
ptr_stu?head?=?init_list();?//鏈表初始化,創建無數據的頭結點
choice(head);?//調用選擇函數
return?0;
}
//1.初始化創建頭結點
ptr_stu?init_list(void)
{
ptr_stu?head?=?malloc(sizeof(list_stu));
if(head?!=?NULL)
{
head->next?=?NULL;
}
return?head;
}
//2.創建一個節點
ptr_stu?creat_node(void)??
{
ptr_stu?new?=?malloc(sizeof(list_stu));
if?(new?!=?NULL)
{
printf(“請輸入學號:“);
scanf(“%s“?new->id);
printf(“請輸入姓名:“);
scanf(“%s“?new->name);
printf(“請輸入年齡:“);
scanf(“%d“?&new->age);
printf(“請輸入電話:“);
scanf(“%s“?new->nu);
printf(“請輸入分數:“);
scanf(“%f“?&new->score);
new->next?=?NULL;
}
return?new;
}
//3.插入結點
void?insert_node(ptr_stu?head?ptr_stu?new)
{
if(new?==?NULL?||?head?==?NULL)
return;
ptr_stu?p?=?head;
while(p->next?!=?NULL)
{
if(strcmp(p->next->id?new->id)?==?0)?//判斷學號是否有沖突
{
printf(“\033[41m學號重復!錄入失敗!\033[0m\n“);
return;
}
p?=?p->next;
}
p->next?=?new;
}
//4.遍歷顯示·
void?display_node(ptr_stu?head)
{
if(head->next?==?NULL)
{
printf(“\033[41m系統為空,無學生信息!\033[0m\n“);
return;
}
printf(“\033[34m*********\033[0m?\033[44m學生信息:\033[0m?\033[34m*************\033[0m\n“);
printf(“\033[40m學號\t?????姓名\t??年齡\t電話\t?????成績\033[0m\n“);
ptr_stu?p?=?head;
while(p->next?!=?NULL)
{
p?=?p->next;
printf(“\033[31;40m%-12s\033[0m\033[40m?%-12s?%-4d??%-12s?%-4.1f\033[0m\n“?p->id?p->name?p->age?p->nu?p->score);
}
printf(“\033[34m*********\033[0m?\033[44m可愛的分割線!\033[0m?\033[34m*********\033[0m\n“);
}
//主界面
void?interface(void)
{
printf(“\n===============\033[42m請選擇功能(0-6):\033[0m===============\n“);
printf(“\t?\033[40;31m?1.?\033[0m?\033[33m新建一個學生的信息。\033[0m\n“);
printf(“\t?\033[40;31m?2.?\033[0m?\033[36m刪除某個學生的信息。\033[0m\n“);
printf(“\t?\033[40;31m?3.?\033[0m?\033[32m顯示全部學生的信息。\033[0m\n“);
printf(“\t?\033[40;31m?4.?\033[0m?\033[34m查找某個學生的信息。\033[0m\n“);
printf(“\t?\033[40;31m?5.?\033[0m?\033[35m修改某個學生的信息。\033[0m\n“);
printf(“
評論
共有 條評論