首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
2005年11月15日华为软件研发笔试题。实现一单链表的逆转。
2005年11月15日华为软件研发笔试题。实现一单链表的逆转。
admin
2019-03-29
45
问题
2005年11月15日华为软件研发笔试题。实现一单链表的逆转。
选项
答案
#include "stdafx.h" typedef char eleType; // 定义链表中的数据类型 typedef struct listnode // 定义单链表结构 { eleType data; struct listnode *next; }node; node *create(int n) // 创建单链表,n为节点个数 { node *p = (node *)malloc(sizeof(node)); node *head = p; head->data = ’A’; for(int i=’B’; i<’A’+n; i++) { p = (p->next = (node *)malloc(sizeof(node))); p->data = i; p->next = NULL; } return head; } void print(node *head) // 按链表顺序输出链表中元素 { for(; head; head = head->next) printf("%c ", head->data); printf("\n"); } node *reverse(node *head, node *pre) // 逆转单链表函数。这是笔试时需要写的最主要函数 { node *p=head->next; head->next = pre; if(p) return reverse(p, head); else return head; } int main(int argc, char* argv[]) { node *head = create(6); print(head); head = reverse(head, NULL); print(head); return getchar(); }
解析
转载请注明原文地址:https://kaotiyun.com/show/0xmZ777K
0
程序员面试
相关试题推荐
Nowhereinnatureisaluminumfoundfree,owingtoitsalways______withotherelements,mostcommonlywithoxygen.
"Thecatdoesnotofferservices,"WilliamBurroughswrote."Thecatoffersitself."Butitdoessowithunapologeticcontradict
[A]TherelativelylowtuitionfeesinAsiaarealsoamaindrawforprospectivestudents.Lastyear,onlinehighereducationre
活动目录的作用
在新浪主页中,利用搜索功能,查找“汽车”相关的网站。
通过【控制面板】中的添加硬件向导,安装Modem的驱动程序。让系统自动搜索安装软件,Modem的型号为:IntelV92HaMDataFaxVoice。
将C盘“职称考试”文件夹中的“试题.XLS”的属性设置为只读。
下面哪些属于中国域名()A.MicrosoftB.eeec.comC.ibm……ilD.bta.cn
请在自定义序列“P1,P2,P3,P4”中增加P5。
阅读以下关于税务管理系统方面的叙述,回答问题1和问题2。近年来,我国电子税务工作取得了长足进步,特别是2000年,税务管理信息化工作在国务院领导的直接关心和国家税务总局党组的具体指挥下,以五省四市“金税工程”的顺利开通、平稳运行为标志,取得了突破性
随机试题
(2018年枣庄市中区)班主任王老师在编制课程表时,将体育课和生产劳动课分开排。王老师遵循了课程表安排中的()
我国目前对股票发行申请采取的是()
毒性药品生产、配制时,必须
下列产生工程项目费用偏差的原因中,属于业主原因的有()。
房地产使用代价的租金,也可以叫做()。
学习之间发生迁移时,学习者原有经验的组成要素没有发生变化,即抽象的结构没有变化,只是将一种学习中习得经验的组成要素重新组合并移用于另一种学习之中。这种迁移属于()。
现代领导班子,不仅要求每个成员具备良好的个体素质,而且还要求整个领导班子具备()
我国《物权法》第6条规定:“不动产物权的设立、变更、转让和消灭,应当依照法律规定登记。动产物权的设立和转让,应当依照法律规定交付。”请分析:如何理解本条规定中的“登记”和“交付”的含义?
•Youwillhearthreeconversations.•Writedownoneortwowordsoranumberinthenumberedspacesonthenotesorforms.•Afte
Weshouldalwaysbearinmindthat______decisionsoftenresultinseriousconsequences.[1999]
最新回复
(
0
)