| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 537 人关注过本帖
标题:数据结构
取消只看楼主 加入收藏
fanbt50
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-4-22
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:0 
数据结构
# include<stdio.h>
# include<stdlib.h>
typedef struct linknode
{int data;
struct linknode *next;
}node, *linklist;
void Createlist(linklist L)
{node *head,*p,*s;
int n=0,z=1;
int x;
head=malloc(sizeof(node));
p=head;
printf("\n\t\t 建立一个线性表");
printf("\n\t\t 请逐个输入结点,以"x"未结束标记! \n");
while(z)
{printf("\t\t 输入:");
scanf("%c",&x);
getchar();
if(x!='x')
{s=NULL;
n++;
s->data=x;
p->next=s;
s->next=NULL;
p=s;
}
else z=0;
}
}
int Lenlist(linklist L)
{node *p=L;
int n=0;
while(p->next)
{p=p->next; n++ }.....................................................(34)
return n;
}
node *Searchlist(linklist L,int i)
{node *p=L;
int j=0;
while(p->next!=NULL&&j<1)
{p=p->next;
    j++;
}
if(j==1)
return p;
else
return NULL;
}
void Inslist(linklist L,int i,int x)
{node *head,*s,*p;
int n,j=0;
p=head;
while(p!=NULL&&j<1)
{j++;
p=p->next;
}
if(p!=NULL)
{s=NULL;
    s->data=x;
    s->next=p->next;
    p->next=s;
    n++;
}
else
printf("\n\t\t线性表为空或插入位置超出! \n");.............................................(14)
}
void Dellist(linklist L,int x)
{int n;
node *head,*p,*q;
if(head==NULL)
{printf("\t\t链表下溢! \n");
return;
}
if(head->next==NULL)
{printf("\t\t线性表已经为空!\n");
return;
}
q=head;
p=head->next;
while(p!=NULL&&p->data!=x)
{q=p;
p=p->next;
}
if(p!=NULL)
{q->next=p->next;
delete (P);..................................................................(86)
n--;
printf("\t\t %c已经被删除!",x);
}
else
printf("\t\t未找到!\n");
}
void main()
{linklist L;
int n=0,i;
int x;
Createlist(L);
Lenlist(L,n);.............................................................(98)
Searchlist(L,i);
Inslist(L,i,x);
Dellist(L,x);
}
请帮看看,我运行了搞不出来啊。。。(14) (34) (86) (98)有错!!!!!!!!!!!!!
搜索更多相关主题的帖子: 数据结构 
2010-04-26 20:48
快速回复:数据结构
数据加载中...
 
   



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

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