#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;free(p); } else { q->next=p->next; free(p) ; }
q=p=head; printf("\n"); while (p->next != NULL)
{ printf("%c ",p->lk); p=p->next; } /* printf("\n"); */
q=p=head;
printf("\n2:input deleted letter"); scanf("%c",&ch);
}
}
大家运行一下就知道了````