#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
int data;
Node *next;
};
void headinsert(Node **head,int newdata){
//头插法先建立一个新的连续的内存存储区
Node *newnode=(Node*)malloc(sizeof(Node));
newnode->data=newdata;
newnode->next=*head;
*head=newnode;
return ;
}
void clear(Node * head){
if(head==NULL) return ;
for(Node *p=head,*q;p;p=q){
q=p->next;
free(p);
}
return ;
}
int main(void){
Node *head=NULL;
int num;
for(int i=0;i<5;i++){
scanf("%d",&num );
headinsert(&head,num );
}
Node *cur=NULL;
cur=head;
while(cur!=NULL){
printf("cur->data=%d\n ",cur->data);
cur=cur->next;
}
clear(head);
return 0;
}