鍊錶的插入和刪除 學生成績錄入程式管理

2021-09-05 01:35:29 字數 1281 閱讀 2532

改進單向鍊錶學生成績錄入,增加新增刪除函式,再輸入結束後通過新增刪除函式來更改鍊錶,遍歷輸出。

#include "stdafx.h"

struct student

;typedef struct student node;

typedef node* ptr;

int main()

else

if(num=2)

return0;

}ptr creatlink()

last = head;

scanf_s

("%d"

,&num)

;while

(num !=0)

previous-

>next = last;

scanf_s

("%d"

,&num);}

previous-

>next =

null

;free

(last)

;return head;

}void

insert

(ptr head)

temp-

>grade = num;

if(num==1)

//如果插入點在第乙個結點之前 將head指標指向第乙個結點 (新結點成為第乙個結點)

else

//如果插入的不是第乙個結點,找到位置正常插入即可。

previous-

>next = temp;

//上乙個last結點next指標指向temp temp的next指標指向最後的last結點 成功新增

temp-

>next = last;

}printf_s

("插入成功 當前成績為:");

while

(head !=

null)}

void

delete

(ptr head)

if(previous!=

null

)//previous不是空 那麼就是不刪除頭結點的情況

else

//如果被刪除的是第乙個結點,將head指標指向第二個結點釋放第乙個結點

printf_s

("刪除成功 當前成績為:");

C語言鍊錶實現簡單的學生成績錄入系統

如下 include include include include include define format d n s n f n f n f n define len sizeof stu typedef struct studentstu int n int tips 建立學生資訊 stu...

函式題 學生成績煉表處理

本題要求實現兩個函式,乙個將輸入的學生成績組織成單向鍊錶 另乙個將成績低於某分數線的學生結點從鍊錶中刪除。函式介面定義 struct stud node createlist struct stud node deletelist struct stud node head,int min scor...

學生成績管理系統(鍊錶的實現)

所使用的標頭檔案 include include include 所呼叫的函式 struct link node creat struct link node head 建立新結點 int count node struct link node head 結點計數 void delete node ...