首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
2005年11月15日华为软件研发笔试题。实现一单链表的逆转。
2005年11月15日华为软件研发笔试题。实现一单链表的逆转。
admin
2019-03-29
147
问题
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
程序员面试
相关试题推荐
______mancannowcreateradioactiveelements,thereisnothinghecandotoreducetheirradioactivity.
ALetterofApplicationforStudy求学信Writealetterofabout100wordsbasedonthefollowingsituation:Youwanttoapplyfor
RememberNapsterorGrokster?Bothservicesalloweduserstosharecomputerfiles—usuallydigitalmusic—thatinfringedthecopyr
Asthelatestcropofstudentspentheirundergraduateapplicationformandweighuptheiroptions,itmaybeworthconsidering
概述o/rmapping的原理
根据委托(delegate)的知识,请完成以下用户控件中代码片段的填写:namespacetest{publicdelegatevoidOnDBOperate();publicclassUserControlBase
在不重新启动计算机的情况下切换用户。
将一个幻灯片上多个已选中自选图形组合成一个复合图形,使用()A.编辑菜单B.快捷菜单C.格式菜单D.工具菜单
在Excel97中,要在活动单元格内输入当天日期可使用组合键()。A.Ctrl+“:”B.Ctrl+Shift+“:”C.Alt+“:”D.Alt+Shift+“:”
软盘写保护的作用是()。A.防止持签B.防止读盘C.防止显示D.防止写盘
随机试题
会计核算形式
在创业阶段,组织的薪酬体系应该是()
水工建筑物的地基处理中能够提高地基防渗性的方法有()。
下列有关契税的处理符合税法规定的有()。
【2012年】下列各项费用预算项目中,最适宜采用零基预算编制方法的是()。
山东境内江河水系由()组成。
设f’(x)在[0,1]上连续且|f’(x)|≤M.证明:
IP数据报经过:MTU较小的网络时需要分片。假设一个大小为1500的报文分为2个较小报文,其中一个报文大小为800字节,则另一个报文的大小至少为_____________字节。
Thepurposeofthepassageistoconvincereadersthat,bystudyingcomputersathome,peoplecanbecome______.Accordingtot
Afterabusyday,PresidentLincolnandwife【M1】______wenttoFord’sTheatreinWashingtonDC,
最新回复
(
0
)