链表就是由两块部分组成的,一是数据,二是指针。
太难了明天再战。
一礼拜过后,
好的我回来啦,经过大量的视频轰炸我好像看懂了什么。。。。。
#include <stdio.h>
#include <stdlib.h>
typedef struct n{
int save;
struct n *next;
}Node;
int main()
{
Node *head = NULL;
// 指针的主要步骤定义一个头
int n;
while (scanf("%d",&n)&&n+1){
Node *p = (Node*)malloc(sizeof(Node));
p->save = n;
p->next = NULL;
// 现在我要遍历找到原来储存的最后一个链表节点
Node *last = head;
if (last){//还要判断那个last有没有数据,可能只有head
while (last->next){
last = last->next;
}
last = p;// 哈哈,把p给接上了
}else {
head = p;
}
}
return 0;
}