#include<stdio.h>
#include<stdlib.h>
typedef struct Node {
int data;
struct Node *next;
} Node,*LinkList;
LinkList L;
Node *CreateFromHead();
void DisplyNode();
main() {
char c;
L=(LinkList)malloc(sizeof(Node));
L->next=NULL;
printf("DO you want to appent a new node(Y/N)?");
scanf("%c",&c);
while(c=='Y'||c=='y') {
L=CreateFromHead();
DisplyNode(L);
printf("DO you want to appent a new node(Y/N)?");
fflush(stdin);
scanf("%c",&c);
}
}
Node *CreateFromHead() {
Node *s;
int c;
printf("Input node data:");
scanf("%d",&c);
s=(Node *)malloc(sizeof(Node));
s->data=c;
s->next=L->next;
L->next=s;
return(L);
}
void DisplyNode() {
Node *p=L;
int j=1;
while(p!=NULL) {
printf("%5d%10d\n",j,p->data);
p=p->next;
j++;
}
}