#include "stdio.h"
#include "stdlib.h"
#define N sizeof(struct node)
//链表结构体
typedef struct node{
struct node *next;
int data;
}*pnode;
//条件创建链表(头插)
pnode create1(){
pnode head,p,q;
p=q=(pnode)malloc(N);
q=NULL;
scanf("%d",&p->data);
while(p->data!=0){
p->next=q;
q=p;
p=(pnode)malloc(N);
scanf("%d",&p->data);
}
head=q;
return head;
}
//条件创建链表(尾插)
pnode create2(){
pnode head,p,q;
p=q=(pnode)malloc(N);
head=NULL;
q->next=NULL;
scanf("%d",&p->data);
while(p->data!=0){
if(head==NULL)
head=p;
else
q->next=p;
q=p;
p=(pnode)malloc(N);
scanf("%d",&p->data);
}
q->next=NULL;
return head;
}
//链表的循环(头插)
pnode precreate(int n){
pnode p,head,q;
q=(pnode)malloc(N);
q=NULL;
#include "stdlib.h"
#define N sizeof(struct node)
//链表结构体
typedef struct node{
struct node *next;
int data;
}*pnode;
//条件创建链表(头插)
pnode create1(){
pnode head,p,q;
p=q=(pnode)malloc(N);
q=NULL;
scanf("%d",&p->data);
while(p->data!=0){
p->next=q;
q=p;
p=(pnode)malloc(N);
scanf("%d",&p->data);
}
head=q;
return head;
}
//条件创建链表(尾插)
pnode create2(){
pnode head,p,q;
p=q=(pnode)malloc(N);
head=NULL;
q->next=NULL;
scanf("%d",&p->data);
while(p->data!=0){
if(head==NULL)
head=p;
else
q->next=p;
q=p;
p=(pnode)malloc(N);
scanf("%d",&p->data);
}
q->next=NULL;
return head;
}
//链表的循环(头插)
pnode precreate(int n){
pnode p,head,q;
q=(pnode)malloc(N);
q=NULL;