实现嵌套链表

本文介绍了一道编程题目,要求在程序设计中实现带有嵌套功能的DouList数据结构。该结构允许链表内的元素可以是其他链表,即形成嵌套链表。题目要求在原有DouList的基础上进行改进,使front()和back()函数返回嵌套的DouList,同时确保代码向下兼容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

程序设计里面作业的一道题,感觉我们的助教师兄出的很好,考到了很多指针的知识


题干如下

You guys must have seen nested list (嵌套链表) such as [1, 2, 3, [4, 5, [6, 7]], 8, [9, 0]].

So your task is to improve DouList with nested feature. You can directly copy the codes submitted before and make changes on it. But pay attention to something which had been changed in header file.

 DouList

NOTICE 1:

front() / back() now returns a DouList
for example : a = [1, 2, 3, [4, 5, [6, 7]], 8, [9, 0]]
a.front() returns [1]
a.back() returns [9, 0]

NOTICE 2:

make sure the codes in the first version of DouListTest.cpp will still work well as before, consider how to make codes compatible.
(保持向下兼容)

/*头文件DouList.h*/

    #ifndef SSCPP2014_DOULIST_A_H
    #define SSCPP2014
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值