| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:请教一下我这个数据结构程序的错误,给改一下
只看楼主 加入收藏
魏刚
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2007-9-23
收藏
 问题点数:0 回复次数:1 
请教一下我这个数据结构程序的错误,给改一下

typedef struct node
{
int data;
struct Note *next;
} Node, *Linklist;
Linklist GreateFromTail() /*jianbiao*/
{ Linklist L;
Node *r,*s;
int flag=1;
L=(Node *)malloc(sizeof(Node));
L->next=NULL;
r=L;
while(flag)
{
c=getchar();
if(c!='$')
{
s=(Node *)malloc(sizeof(Node));
s->data=c;
r->next=s;
r=s;
}
else
{ flag=0;
r->next=NULL;
}
}
return L;
}
Node *Get (Linklist L,int i) /*qiuquyuansu*/
{ int j;
Node *p;
p=L; j=0;
while(p->next!=NULL&&j<i)
{
p=p->next;
j++;
}
if(i==j)
return p;
else return NULL;
}
Node *Locata (Linklist L, int e ) /*dingwei*/
{ Node *p;
p=L->next;
while(p!=NULL&&p->data!=e);
p=p->next;
return p;
}
int Inslist (Linklist L,int i,int e)
{ Node *pre, *s;
int k;
pre=L; k=0;
while(pre!=NULL&&k<i-1)
{ pre=pre->next;
k=k+1;
}
if(k!=i-1)
{ printf("cha ru wei zhi bu he li");
return(ERROR);
}
s=(Node *)malloc(sizeof(Node));
s->data=e;
s->next=pre->next;
pre->next=s;
return OK;
}
int DeiList(LinkList,int i,int *e) /*shanchu*/
{ Node *p,*r;
int k;
p=L;k=0;
while(p->next!=NULL&&k<i-1)
{ p=p->next;
k=k+1;
}
if(k!=i-1)
{ printf("shan chu jie dian wei zhi bu he li")
return ERROR;
}
r=p->next;
p->next=p->next->next;
*e=r->data;
free(r);
return ok;
}
inr ListLength (Linklist L) /*qiuchangdu*/
{ Node *p;
p=L->next;
j=0;
while(p!=NULL)
{p=p->next;
j++;
}
return j;
}
void main()
{
printf(" ___________________________");
printf(" |(1)Creat a new linklist. |\n");
printf(" |(2)Locate. |\n");
printf(" |(3)Get element. |\n");
printf(" |(4)The length of linklist. |\n");
printf(" |(5)Inside an element. |\n");
printf(" |(6)Delete an element. |\n");
printf(" |(7)EXIT. |\n");
printf(" |___________________________|\n");
printf("Please input the number of your choose.\n");
}

{ int c,exit,e=0,i;
Node *L,*t;
char a;
printf("do you want Gread From Tial?\n");
scanf("%c",&c);
if(c!='Y'&&c!='y')
return 0;
L=Gread From Tail();
while(exit!=0)
printf("1,getlist\n 2,locatelist\n 3,Inslist\n 4,Delistlist\n 5,listlength\n");
switch(c)
{
case1:
{
printf("please input data you want to get:");
scanf("%d",&e);
t=get(L,e);break;
}
case2:
{
printf("please input data number you want to find:");
scanf("%d",&e);
t=locate(L,e)
printf("pate is :%d",t->data);
break;
}
case3:
{
printf("please input data ");
printf("n=");scanf("%d",&i);
printf("e=");
scanf("%d",&e);
t=znsliot(L,e);
break;
}
case4:
{
printf("please input data is slte(i) which you want to delet\n");
printf("n=");
scanf("%d",&n);
delist(L,i);
break;
}
case5:
{
printf("list hare %d data\n");
listLength(L);
break;
}
}


2007-09-30 00:20
andself
Rank: 1
等 级:新手上路
帖 子:60
专家分:0
注 册:2007-9-23
收藏
得分:0 
晕 和我的好象啊 错太多了啊 ~~~
比我惨多了啊 努力 啊

2007-09-30 12:33
快速回复:请教一下我这个数据结构程序的错误,给改一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016747 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved