#include <stdio.h>
#define len sizeof(struct a)
#define NULL 0
struct a
{char lk;
struct a *next ;
};
main()
{struct a *head,*p,*q;
int i;
char ch;
head=p=(struct a *) malloc(len);
for(i=1;i<=26;i++)
{(p->lk)=('a'+i-1);
p->next=(struct a *)malloc(len);
p=p->next;
}
p->next=NULL;
p=head;
while (p->next != NULL)
{ printf("%c ",p->lk);
p=p->next;
}
printf("\n");
q=p=head;
printf("input deleted letter:");
scanf("%c",&ch);
while(ch != '0')
{ while(p->lk != ch && p->next != NULL)
{q=p;
p=p->next;}
if(p==head)
head=head->next;
else
q->next=p->next;
free(p) ;
p=head;
while (p->next != NULL)
{ printf("%c ",p->lk);
p=p->next;
}
/* printf("\n"); */
q=p=head;
printf("2:input deleted letter");
scanf("%c",&ch);
}
}
我又改成这样了
如果 输入a ,它把a和z都删了
输入b,它把b和y都删了```