鍊錶實現學生資訊儲存(01)

2021-10-01 07:35:00 字數 2497 閱讀 2563

#include

#include

#define pt "學號:%ld 姓名:%-10s 性別:%c\n",p->num,p->name,p->***

#define n sizeof(struct student)

struct student

;struct student *

creat

(struct student *head)

;//初始化鍊錶/建立鍊錶

intlistlength

(struct student *head)

;//計算學生個數

struct student *

listinsert

(struct student *head)

;//插入乙個結點

struct student *

listdelete

(struct student *head)

;//刪除乙個指定結點

void

listget

(struct student *head)

;//查詢指定的資料元素

void

print

(struct student *p)

;//輸出全班學生資訊

intmain()

if(n==0)

//0--結束

printf

("感謝使用!\n");

else

//分支選擇結構結束

}//else的結尾

return0;

}//mian函式的結尾

struct student *

creat

(struct student *head)

//初始化鍊錶/建立鍊錶

return head;

//返回建立的鍊錶

}void

print

(struct student *head)

//輸出全班學生資訊

}int

listlength

(struct student* head)

//求當前元素個數

return size;

}struct student *

listinsert

(struct student *head)

//插入乙個結點

if(j!=i-1)

//正確的找到了插入的位置再連線前面

q->next=p->next;

//先連線後面

p->next=q;

//再連線前面

return head;

//結點已經插入鍊錶,原始鍊錶發生變化,變成新鍊錶,返回指向新鍊錶的指標

}struct student *

listdelete

(struct student *head)

//刪除乙個結點

if(j!=i-1)

printf

("刪除位置出錯!");

s=p->next;

//s接受要刪除的結點

p->next=p->next->next;

//刪除結點

free

(s);

//釋放記憶體

return head;

}void

listget

(struct student *head)

//查詢相應的資料元素

if(j!=i-1)

s=p->next;

s->next=

null

;printf

("學號:%ld 姓名:%-10s 性別:%c\n"

,s->num,s->name,s->***);}

![在這裡插入描述]

20191206200817153.png?x-oss-process=image/watermark,type_zmfuz3pozw5na**pdgk,shadow_10,text_ahr0chm6ly9ibg9nlmnzzg4ubmv0l3h1zxpozv9fx19f,size_16,color_ffffff,t_70)

![在這裡插入描述](https:20191206200524866.png?x-oss-process=image/watermark,type_zmfuz3pozw5na**pdgk,shadow_10,text_ahr0chm6ly9ibg9nlmnzzg4ubmv0l3h1zxpozv9fx19f,size_16,color_ffffff,t_70)

![在這裡插入描述](https:20191206200825889.png?x-oss-process=image/watermark,type_zmfuz3pozw5na**pdgk,shadow_10,text_ahr0chm6ly9ibg9nlmnzzg4ubmv0l3h1zxpozv9fx19f,size_16,color_ffffff,t_70)

鍊錶實現學生管理系統

include include include define maxlen 100 struct data 定義鍊錶的元素個體 typedef data elemtype struct sqlist 建立鍊錶 sqlist createlist sqlist l r next null printf...

使用單向鍊錶實現學生資訊管理系統

全部 實現的功能 選單介面 please enter your choice 1 exit.2 add all students.3 show all students.4 add a studeng.5 remove a studeng.用來存放學生資訊的結構體 9 學生分數的結構體 10type...

C語言鍊錶實現學生管理系統

include include include include include include using namespace std typedef struct ndoestudent struct student 建立學生資訊 student insert student head r nex...