#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
Node* next;
};
void tailInvert(int* data);
void headInvert(int* data);
int main() {
int data[5] = {1, 2, 3, 4, 5};
tailInvert(data);
printf("\n");
headInvert(data);
}
void tailInvert(int* data) {
Node* pHead = (Node*)malloc(sizeof(Node));
Node* pCurr = NULL;
Node* pTail = pHead;
for(int i = 0; i < 5; ++i) {
pCurr = (Node*)malloc(sizeof(Node));
pCurr -> data = data[i];
pTail -> next = pCurr;
pTail = pCurr;
}
pTail -> next = NULL;
printf("尾插法:\n");
for(int j = 0; j < 5; ++j) {
printf("%d\t", pHea
利用头插法建立一个带头结点的的线性链表,链表中依次插入26个小写的英文字母,显示该链表中所有元素,将第十个字母删除后再显示该链表中剩下的元素(提问为什么这么写不对)
最新推荐文章于 2023-10-11 22:58:41 发布