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");
printf("2:input deleted letter"); scanf("%c",&ch);
}
}
----------------解决方案--------------------------------------------------------
人 呢`````
----------------解决方案--------------------------------------------------------
#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都删了```
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------