void fun (SLIST *h,int x){ SLIST *p,*q,*s;s=(SLIST*) malloc (sizeof (SLIST)); s->data=x;q=h;p=h->next;while(p!=NULL && x>p->data) {q=p;p=p->next;}s->next=p;q->next=s;}

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 18:16:38
void fun (SLIST *h,int x){ SLIST *p,*q,*s;s=(SLIST*) malloc (sizeof (SLIST)); s->data=x;q=h;p=h->next;while(p!=NULL && x>p->data) {q=p;p=p->next;}s->next=p;q->next=s;}

void fun (SLIST *h,int x){ SLIST *p,*q,*s;s=(SLIST*) malloc (sizeof (SLIST)); s->data=x;q=h;p=h->next;while(p!=NULL && x>p->data) {q=p;p=p->next;}s->next=p;q->next=s;}
void fun (SLIST *h,int x)
{ SLIST *p,*q,*s;
s=(SLIST*) malloc (sizeof (SLIST));
s->data=x;
q=h;
p=h->next;
while(p!=NULL && x>p->data) {
q=p;
p=p->next;
}
s->next=p;
q->next=s;
}

void fun (SLIST *h,int x){ SLIST *p,*q,*s;s=(SLIST*) malloc (sizeof (SLIST)); s->data=x;q=h;p=h->next;while(p!=NULL && x>p->data) {q=p;p=p->next;}s->next=p;q->next=s;}
SLIST应该是个含有int data,SLIST * next的结构体这段代码就是分配一个SLIST类型的结构体,并将其插入原列表(原列表按data字段升序排序号得,插入之后顺序保持不变),C指针太难搞了