#include<stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
struct node *head=NULL;
struct node *tail=NULL;
void addtail(int data)
{
struct node *sta =(struct node*)(malloc(sizeof(struct node)));
sta->data=data;
sta->next=NULL;
if(head==NULL||tail==NULL)
{
head=sta;
tail=sta;
}
else
{
tail->next=sta;
tail=sta;
}
}
void addhead(int data)
{
struct node*sta=(struct node*)malloc(sizeof(struct node));
sta->data=data;
sta->next=NULL;
if(head==NULL)
{
head=sta;
tail=sta;
}
else
{
sta->next=head;
head=sta;
}
}
#include<stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
struct node *head=NULL;
struct node *tail=NULL;
void addnode(int data)
{
struct node *sta =(struct node*)(malloc(sizeof(struct node)));
sta->data=data;
sta->next=NULL;
if(head==NULL||tail==NULL)
{
head=sta;
tail=sta;
}
else
{
tail->next=sta;
tail=sta;
}
}
void addhead(int data)
{
struct node*sta=(struct node*)malloc(sizeof(struct node));
sta->data=data;
sta->next=NULL;
if(head==NULL)
{
head=sta;
tail=sta;
}
else
{
sta->next=head;
head=sta;
}
}
struct node *select(int data)
{
struct node *middle=head;
while(middle!=NULL)
{
if(data==middle->data)
{
return middle;
}
middle=middle->next;
}
return NULL;
};
void sea()
{
struct node *middle=head;
while(middle!=NULL)
{
printf("%d\n",middle->data);
middle=middle->next;
}
}
int main(void)
{
int a[10]= {1,2,3,4,5,6,7,8,9,10};
int i;
for(i=0; i<10; i++)
{
addhead(a[i]);
}
sea();
return 0;
}
void Free()
{
struct node *middle=head;
while(middle!=NULL)
{
struct node *pt=middle;
middle=middle->next;
free(pt);
}
head=NULL;
tail=NULL;
}