struct node{
int date;
struct node* next;
}创建链表过程就不写了,亲。
void Delete_X(struct node* h,int x)
{
struct node *p,*q
for(p=h,q=NULLpq=p,p=p->next){
if(p->date==x){
if(!q){ //如果删除的元素是头结点
h=q->next
p->next=NULL
}//endif
else{
q->next=p->next
p->next=NULL
}//endelse
}//endif
}//endfor
}//end
void demo(sqlisttp *L){
int i = 1, j = 0
while (__i<lenth___ )//当i<length结束
{
if (L->elem[i] != L->elem[j])//如果不相等,则执行将下表为i的值存入下表为j+1的地方 j移动到j+1
{
___j++______
___L->elem[j]=L->elem[i]__
}
i++//i移动到i+1
}
___L->lenth=j+1____
}
这个题目就是让我们这么做的
花了好长时间想通了,但是这个算法有bug,将数据代入1123451时就不行了,
脑细胞死了好多,求accept挽回点损失
# include <stdio.h>void del(char *p)
{
char *p1=p
while(*p1++)
{
if(*(p1-1)>='0'&&*(p1-1)<='9')
*p++=*(p1-1)
}
*p='\0'
}
main()
{
char str[]="a1bc2345df"
del(str)
printf("%s\n",str)
}