求哪位高手可以解答一下啊

初出茅庐之新 2011-10-26 01:17:32
#include "stdio.h"
#include "stdlib.h"

#define T sizeof( struct node)
struct node
{ char data;
struct node *next;
};

struct node *l( )
{
char x;
struct node *p,*h,*l;
l=(struct node*)malloc(T);

l->next=NULL;
h=l;

scanf("%c",&x);

while(x!='&')
{ p=(struct node *)malloc(T);
p->data=x;
p->next=h->next;
h->next=p;
h=p;
scanf("%c",&x);
}
return l;
}
void outlin(struct node *l)
{ struct node *p;
p=l->next;
while(p!=NULL)
{ printf("%c",p->data);
p=p->next;

}

}
void shanchu(struct node *l,int y)
{ struct node *p,*s;
int i; i=0;


p=l->next;

while (i!=y-2&&p->next!=NULL)
{ i++;
p=p->next;
}
if(i==y-1)
{
s=p->next;
p->next=s->next;
free(s);
}
printf("找不到这位!!");
}
main()
{ struct node*q;
int a;
q=l();
scanf("%d",&a);





shanchu(q,a);
outlin(q);
}
...全文
82 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
chhch11111 2011-10-26
  • 打赏
  • 举报
回复
自己至少要把出错的地方调试出来吧。
基本上没人会那么闲一句一句的帮你找出错的语句的。
初出茅庐之新 2011-10-26
  • 打赏
  • 举报
回复
不行啊,所以才请教啊
exCs_dn 2011-10-26
  • 打赏
  • 举报
回复
一个小程序,正常运行不行么?

33,006

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧