创建结构体
typedef struct NODE{
int calue;
NODE*nextPtr;
}storeNODE;
typedef struct LIST{
storeNODE*head;
storeNODE*tail;
}storeLIST;
void add_node(storeLIST*index)
{
int num;
scanf("%d",&num);
index->head=(storeNODE*)malloc(sizeof(storeNODE));
index->head->nextPtr=NULL;
index->tail=index->head;
while(num!=-1)
{
storeNODE*last=index->tail;
storeNODE*p;
p=(storeNODE*)malloc(sizeof(storeNODE));
p->value=num;
p->nextPtr=NULL;
last->nextPtr=p;
index->tail=p;
scanf("%d",&num);
}
}
void print_node(storeLIST*index)
{
storeNODE*p;
for(p=index->head->nextPtr;p;p=p->nextPtr)
printf("%d",p->value);
}
void mend_Ptr_node(storeLIST*index)
{
storeNODE*p;
for(p=index->head->nextPtr;p;p=p->nextPtr)
index->tail=p;
void creat_vacant_node(storeLIST*index)
{
index->head=(storeNODE*)malloc(sizeof(storeNODE));
index->head->nextPtr=NULL;
index->tail=index->head;
}
int judge_ifvacant_node(storeLIST*index)
{
return (index->head->nextPtr!=NULL);
}
void over_node(storeLIST*index)
{
storeNODE*p,*q;
for(p=index->head;p;p=q)
{
q=p->nextPtr;
free(p);
}
}
void bubblesort_node(storeLIST*index)
{
storeNODE*pfirst=NULL,storeNODE*pend=NULL;
int temp;
pfirst=index->head;
while(pfirst!=NULL)
{
while(pfirst->nextPtr!=NULL)
{
if(pfirst->value<pfirst->nextPtr->value)
{
temp=pfirst->value;
pfirst->value=pfirst->nextPtr->value;
pfirst->nextPtr->value=temp;
}
pfirst=pfirst->nextPtr;
}
pend=pfirst;
pfirst=pfirst->nextPtr;
}
}