在长度大于1的循环列表中,既无头结点也无根结点,S维指向列表中的某个节点指针,删除这个S结点的前续结点

来源:百度知道 编辑:UC知道 时间:2024/06/19 21:51:06
需要详细的过程......... 急!!!!!!!!!!!!!只限明天下午之前!!!!!!!!!!!!!!!!!!!!!答对还加分!!!!!!!!!

#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
struct m
{
int data;
struct m *next;
};
typedef struct m LB;
LB *creat(void);
void out(LB *);
void del(LB *);
void main()
{
LB *head=NULL;
if((head=creat())==NULL)
{
printf("链表建立失败~!\n");
exit(0);
}
del(head);
}
LB *creat(void)
{
LB *head=NULL,*p,*s;
char c[5];
int i=1,x;
system("CLS");
s=(LB *)malloc(sizeof(LB));
printf("请输入数据:");
gets(c);
s->data=atoi(c);
while(i)
{
if(head==NULL) head=s;
else p->next=s;
p=s;
printf("请输入数据(ok结束,输入后按回车继续输入):");
gets(c);
if(strcmp(c,"ok")==0) break;
s=(LB *)malloc(sizeof(LB));
s->data=atoi(c);
}
p->next=head;
return head;