#include <stdio.h>
#include <stdlib.h> //由于要使用malloc()函数,需要加载该头文件
struct linked_list //创建结构体,即链表的每个节点,用于储存数据和下一个节点的地址
{
int date;
struct linked_list *next;
};
int main(void)
{
int n;
struct linked_list *p,*t,*head;
head=p=t=NULL;
scanf("%d",&n); //n用来限制排序的数目,及链表节点的个数
while(n--)
{
p=(struct linked_list *)malloc(sizeof(struct linked_list)); //先用p指向一块动态内存,即一个节点
scanf("%d",&p->date);
if(NULL==head) //若是第一个节点,则将头指针指向该节点
{
head=p;
p->next=NULL;
}
else //若不是第一个节点,则需要
#include <stdlib.h> //由于要使用malloc()函数,需要加载该头文件
struct linked_list //创建结构体,即链表的每个节点,用于储存数据和下一个节点的地址
{
int date;
struct linked_list *next;
};
int main(void)
{
int n;
struct linked_list *p,*t,*head;
head=p=t=NULL;
scanf("%d",&n); //n用来限制排序的数目,及链表节点的个数
while(n--)
{
p=(struct linked_list *)malloc(sizeof(struct linked_list)); //先用p指向一块动态内存,即一个节点
scanf("%d",&p->date);
if(NULL==head) //若是第一个节点,则将头指针指向该节点
{
head=p;
p->next=NULL;
}
else //若不是第一个节点,则需要