| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 467 人关注过本帖
标题:求助数据结构的问题
只看楼主 加入收藏
yuanman_2008
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-11-17
收藏
 问题点数:0 回复次数:0 
求助数据结构的问题
#include<stdio.h>
#include<math.h>
#define null 0
typedef int datatype;
typedef struct snode
{ datatype data;
struct snode *next;
}lsnode;
lsinitiate(lsnode **head)
{ (*head)->next=null;
}
lspush(lsnode *head, datatype x)
{ lsnode *p;
if((p=(lsnode *)malloc(sizeof(lsnode)))==null) exit(1);
p->data=x;
p->next=head->next;
head->next=p;
}
lspop(lsnode *head, datatype *d)
{ lsnode *p=head->next;
if(p==null)
{ printf("堆栈已空出错!");
return 0;
}
head->next=p->next;
*d=p->data;
free(p);
return 1;
}
lsgettop(lsnode *head, datatype *d)
{ lsnode *p=head->next;
if(p==null)
{ printf("堆栈已空出错!");
return 0;
}
*d=p->data;
return 1;
}
lsnotempty(lsnode *head)
{ if(head->next==null) return 0;
else return 1;
}
print(lsnode *head)
{ int x;
while(lspop(head,&x))
printf("%3d",x);
}
main()
{ lsnode L;
int i,x;
clrscr();
lsinitiate(&L);
for(i=0;i<=10;i++)
lspush(&L,i);
print(&L);
}
问题出在print 函数里!!
搜索更多相关主题的帖子: 数据结构 
2007-11-17 15:25
快速回复:求助数据结构的问题
数据加载中...
 
   



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

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