實現乙個單鏈表的建立 測長 列印,插入,排序,逆置

2021-07-05 16:38:26 字數 1033 閱讀 9487

/*

taotao definition

created by taotao man on 2015-9-30

brief: 實現乙個單鏈表的建立、測長、列印,插入,排序,逆置

// 修改記錄

date:

add seta();

set geta();

*/#include "stdio.h"

#include#include // conio是console input/output(控制台輸入輸出)的簡寫

using namespace std;

typedef struct student

node;

node *creat() // 單鏈表的建立

else

cycle = 0; }

p->next = null;

head = head->next;

printf("\n第乙個節點 %d", head->data);

return head;

}int length(node *head)

printf("\n該鍊錶的長度為: %d", n);

return n;

}void print(node *head)

}node *insert(node *head, int num) // 單鏈表的插入,num是要插入的數值(預設是遞增順序鍊錶)

if(p1->data >= p0->data)

else

}else

//return head;

}node *sort(node *head) // 單鏈表的排序

p = p->next;

} }return head;

}node *reverse(node *head) // 單鏈表的逆置

head->next = null;

head = p1;

return head;

}void main()

單鏈表的建立測長列印

define crt secure no warnings include include include include using namespace std typedef struct student node node creat else cycle 0 head head next p...

雙鏈表的建立 測長 列印 刪除 插入

include using namespace std struct node int n 0 節點個數 鍊錶的建立,尾插法 struct node create struct node head q p n p new node cin p data p pre null p next null ...

單鏈表的建立 測長和列印

面試寶典中第13章,實現單鏈表的建立測長和列印 include include include includeusing namespace std 單鏈表結構體 typedef struct student node 建立單鏈表 node create else head head next p ...