鍊錶2(鍊錶的建立與遍歷)

2021-10-11 01:31:31 字數 403 閱讀 2208

現有有n個學生的資料記錄,每個記錄包括學號、姓名、三科成績。 編寫乙個函式input,用來輸入乙個學生的資料記錄。 編寫乙個函式print,列印乙個學生的資料記錄。 在主函式呼叫這兩個函式,讀取n條記錄輸入,再按要求輸出。 n<100

#include

typedef struct student

student,*pnode;

student input(int n)

return head;

}void print(pnode head,int n)

}int main()

{ int n;

scanf("%d",&n);

print(input(n),n);

return 0;

鍊錶的建立與遍歷

鍊錶,簡而言之,就是基於鏈式儲存結構下的線性表。鍊錶包括單向鍊錶 雙向鍊錶以及迴圈鍊錶。鍊錶是一種很常用的資料結構,其定義如下 單向鍊錶的定義 定義說明 包括資料域和指標域 typedef int elemtype typedef struct node lnode,linklist 鍊錶的基本操作...

鍊錶(鍊錶建立)

先找到了一些與單鏈表相關的概念 2.指標域 ai元素儲存指向後繼元素儲存位置的資訊 3.結點 包含資料域和指標域 4.單鏈表 每個結點只包含乙個指標域的線性表 5.頭指標 要素 鍊錶中第乙個結點的儲存位置 線性表最後乙個結點指標為空 6.頭結點 非要素 單鏈表第乙個結點前附設乙個結點 其指標域指向第...

鍊錶 建立刪除增加遍歷

linked list 建立鍊錶 include include include struct listnode void createlisthead listnode head,int n p next null 遍歷整個表 void printflist listnode head 刪除整個表...