栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

依次输出链表中的各个结点的递归算法

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

依次输出链表中的各个结点的递归算法

#include

#define ok 1
#define error 0
#define overflow -1

typedef int status;
typedef char selemtype;
using namespace std;

//链表的定义 
typedef struct node
{
	selemtype data;
	struct node *next;
}node,* linklist;

//后插法创建链表算法
status hcfcj(linklist &L,int n)
{
	L=new node;
	L->next=NULL;
	linklist p,r;
	int i;
	r=L;
	for(i=0;i
	p=new node;
	cin>>p->data;
	p->next=NULL;
	r->next=p;
	r=p;
	}
	return ok;
 } 
 
//遍历输出链表中各个结点的递归算法
status blsc(linklist &L)
{
	while(L)
	{
	if(L==NULL)
	  return error;
	else 
		cout<data<<" ";
	L=L->next;
	}
	
	return ok;
}

int main()
{
	int n;
	linklist L;
	cout<<"请输入元素的个数:"<>n;
	cout<<"请输入链表元素:"<next);
	cout<
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/953894.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号