职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 715|回复: 3

c语言程序求助

[复制链接]
cls10000 发表于 2009-8-23 11:04 | 显示全部楼层 |阅读模式
struct node
{int data;
sruct node *next;};
typedef sturct node SLIST;
SLIST *creat_slist()
{int c;/*需要输入的链表数据*/
SLIST *h,*s,*r;/*h头指针
s建立的动态存储单元指针
r链接指针*/
h=(SLIST *)malloc(sizeof(SLIST));
r=h;
scanf(\"%d\",&c);
while(c!=-1)
{s=(SLIST *)malloc(sizeof(SLIST));
s->data=c;
r->next=s;
r=s;
scanf(\"%d\",&c);
}
r->next='\\0';
return h;
}
void printf_slist(SLIST *head)
{SLIST *p;/*指向位置指针*/
p=head->next;
if(p=='\\0') printf(\"linklist is null!\\n\");
else
{printf(\"head\");
do
{printf(\"->%d\",p->data);
p=p->nest;
}while(p!='\\0');
printf(\"the end\\n\");
}
}
void insert_snode(SLIST *head,int x,int y)
{SLIST *s,*p,*q;
s=(SLIST *)malloc(sizeof(SLIST));
s->data=y;
q=head;
p=head->next;
while(p!='\\0'&&p->data!=x)
{q=p;p=p->next;}
s->next=p;
q->next=s;
}
void delete_snode(SLIST*head,int m)
{SLIST *p,*q;
q=head;p=p->next;
while(p!='\\0'&&p->data!=m )
{q=p;p=p->next;
}
if(p->data==m)
q->next=p->next;
}
void screat_snode(SLIST *head,int n)
{SLIST *p;
p=head;
while(p!='\\0'&&p->data!=n)
{p=p->next;}
if(p->data==n)
printf(\"%d\",n);
else
printf(\"not screat snode\\n\");
}
main ()
{SLIST *head;
int x,y,m;/*x定位(要插入数据之后的)数据
y要插入的数据,m要删除的数据*/
scanf(\"%d%d\",x,y);
head= creat_slist();
printf_slist(head);/*链表输出函数*/
screat_snode(head,n);/*链表查找函数*/
insert_snode(hesd,x,y);/*链表插入函数*/
printf_slist(head);
delete_snode(head,m);/*链表删除函数*/
printf_slist(head);
}
哪儿出错了
在tc下无法运行!
超越改 发表于 2009-8-23 11:04 | 显示全部楼层

c语言程序求助

天哪
这么长的程序
编译后
查看错误信息
自己查查错误先!
莲子 发表于 2009-8-23 11:05 | 显示全部楼层

c语言程序求助

改正了
错误还真不少~~~~~~~~~~~~~~~~~~~
#include <stdio.h>
#include <malloc.h>

struct node
{
int data;
struct node *next;
};
typedef struct node SLIST;

SLIST *creat_slist()
{
int c;
//需要输入的链表数据
SLIST *h,*s,*r;
//h头指针
s建立的动态存储单元指针
r链接指针
h = (SLIST *)malloc( sizeof(SLIST) );
r=h;
scanf("%d",&c);
while(c!=-1)
{s=(SLIST *)malloc(sizeof(SLIST));
s->data=c;
r->next=s;
r=s;
scanf("%d",&c);
}
r->next=&#39;\0&#39;;
return h;
}
void printf_slist(SLIST *head)
{
SLIST *p;/*指向位置指针*/
p=head->next;
if(p==&#39;\0&#39;) printf("linklist is null!\n");
else
{printf("head");
do
{printf("->%d",p->data);
p=p->next;
}while(p!=NULL);
printf("the end\n");
}
}
void insert_snode(SLIST *head,int x,int y)
{
SLIST *s,*p,*q;
s=(SLIST *)malloc(sizeof(SLIST));
s->data=y;
q=head;
p=head->next;
while(p!=&#39;\0&#39;&&p->data!=x)
{q=p;p=p->next;}
s->next=p;
q->next=s;
}
void delete_snode(SLIST*head,int m)
{
SLIST *p,*q;
q=head;p=q->next;
while(p!=&#39;\0&#39;&&p->data!=m )
{q=p;p=p->next;
}
if(p->data==m)
q->next=p->next;
}
void screat_snode(SLIST *head,int n)
{
SLIST *p;
p=head;
while(p!=&#39;\0&#39;&&p->data!=n)
{p=p->next;}
if(p->data==n)
printf("%d",n);
else
printf("not screat snode\n");
}
int main ()
{
SLIST *head;
int x,y,m;/*x定位(要插入数据之后的)数据
y要插入的数据,m要删除的数据*/
scanf("%d%d%d",&x,&y,&m);
head= creat_slist();
printf_slist(head);/*链表输出函数*/
screat_snode(head,x);/*链表查找函数*/
insert_snode(head,x,y);/*链表插入函数*/
printf_slist(head);
delete_snode(head,m);/*链表删除函数*/
printf_slist(head);
return 0;
}
小白net 发表于 2009-8-23 11:05 | 显示全部楼层

c语言程序求助

把错误信息发出来看看
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-4-20 19:12 , Processed in 0.151109 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表