#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);
}
}
大家运行一下就知道了````----------------解决方案--------------------------------------------------------
算法太笨还得再改改,你的问题解决方法:
printf("\n2:input deleted letter");
fflush(stdin);//在此加上清流函数
scanf("%c",&ch);
}
}
----------------解决方案--------------------------------------------------------
清流函数是什么呀````???
麻烦给简单的解释一下把```
----------------解决方案--------------------------------------------------------
我晕,怎么还没做出来?
看来我想偷懒是不可能的了
我来看看
----------------解决方案--------------------------------------------------------