当前位置: 首页 > news >正文

网站建设板块如何分类营销型网站建设的5大技巧

网站建设板块如何分类,营销型网站建设的5大技巧,wordpress 仿手机商城,网站开发最快框架[日常练习]练习17:链表头插法、尾插法练习练习17描述输入输出输入示例1输出示例1输入示例2输出示例2代码演示:总结练习17 【日常练习】 链表头插法、尾插法练习 描述 输入3 4 5 6 7 9999一串整数,9999代表结束,通过头插法新建链…

[日常练习]练习17:链表头插法、尾插法练习

  • 练习17
  • 描述
  • 输入
  • 输出
  • 输入示例1
  • 输出示例1
  • 输入示例2
  • 输出示例2
  • 代码演示:
  • 总结


练习17

【日常练习】
链表头插法、尾插法练习


描述

输入3 4 5 6 7 9999一串整数,9999代表结束,通过头插法新建链表,并输出,通过尾插法新建链表并输出。

注意输出要采用如下代码(因为OJ判题对空格敏感,因此需要用下面的打印代码来做):

//打印链表中每个结点的值
void PrintList(LinkList L){L = L->next;//头结点无数据,去第一个结点while (L != NULL){printf("%d", L->data);//打印当前结点数据L = L->next;//指向下一个结点if (L != NULL){printf(" ");//输出案例中,每两个数之间有空格,但是第一个数之前没有空格}}printf("\n");
}

输入

3 4 5 6 7 9999,第二行也是3 4 5 6 7 9999,数据需要输入两次

输出

如果输入是3 4 5 6 7 9999,那么输出是7 6 5 4 3,数之间空格隔开,尾插法的输出是3 4 5 6 7


输入示例1

3 4 5 6 7 9999
3 4 5 6 7 9999

输出示例1

7 6 5 4 3
3 4 5 6 7

输入示例2

1 3 5 7 9 9999
1 3 5 7 9 9999

输出示例2

9 7 5 3 1
1 3 5 7 9


代码演示:

#include <stdio.h>
#include <stdlib.h>#define MaxSize 50
typedef int	ElemType;//数据类型typedef struct LNode//定义单链表结点类型
{ElemType data;//数据域 - 存放数据元素struct LNode* next;//指针域 - 指向下一个结点
}LNode,*LinkList;void ListHeadInsert(LinkList &L)//C++中的引用
{//malloc返回void*类型的,强转成LinkList类型的指针L = (LinkList)malloc(sizeof(LNode)); //分配一个头结点 - 给头结点申请空间 - 一个结构体大小的空间L->next = NULL;//空ElemType x;LinkList s;scanf("%d", &x);while (x != 9999){s = (LinkList)malloc(sizeof(LNode));//给新结点申请空间s->data = x;//把读取到的数据放入新结点的数据域s->next = L->next;//新结点指向原有列表的第一个结点L->next = s;//新结点成为第一个结点scanf("%d", &x);//读取下一个值}
}//OJ判题对空格敏感
//打印链表中每个结点的值
void PrintList(LinkList L){L = L->next;//头结点无数据,去第一个结点while (L != NULL){printf("%d", L->data);//打印当前结点数据L = L->next;//指向下一个结点if (L != NULL){printf(" ");//输出案例中,每两个数之间有空格,但是第一个数之前没有空格}}printf("\n");
}void ListTailInsert(LinkList &L)
{L = (LinkList)malloc(sizeof(LNode));L->next = NULL;ElemType x;LinkList s, r = L;//有一个结点指向尾部scanf("%d", &x);while (x != 9999){s = (LinkList)malloc(sizeof(LNode));//给新结点申请空间s->data = x;//读取的数据放入新结点的数据域r->next = s;//原有链表的尾结点的next,指向新结点r = s;//尾指针指向新的尾结点scanf("%d", &x);}r->next = NULL;//尾结点的next要为NULL
}int main()
{LinkList L; //声明一个指向单链表第一个结点的指针 - 强调这是一个单链表ListHeadInsert(L);//头插法PrintList(L);//头插法后,直接使用尾插法,L指向了另外一个地方,没有free原有链表,属于内存泄漏,做题中没关系。//删除结点一定要freeListTailInsert(L);//尾插法PrintList(L);return 0;
}

总结

本题考查链表的头插法、尾插法,注意打印输出的格式要求,空格的位置。


文章转载自:
http://dinncostereographic.bkqw.cn
http://dinncojehovic.bkqw.cn
http://dinncoremontant.bkqw.cn
http://dinncobeardtongue.bkqw.cn
http://dinncoxhosa.bkqw.cn
http://dinncourticant.bkqw.cn
http://dinncounprotestantize.bkqw.cn
http://dinncofledgeling.bkqw.cn
http://dinncoduring.bkqw.cn
http://dinncoepinaos.bkqw.cn
http://dinncopesthole.bkqw.cn
http://dinncokeratinization.bkqw.cn
http://dinncobursectomize.bkqw.cn
http://dinncolats.bkqw.cn
http://dinncorebellow.bkqw.cn
http://dinncosazerac.bkqw.cn
http://dinncoexdividend.bkqw.cn
http://dinncogrecian.bkqw.cn
http://dinncokeno.bkqw.cn
http://dinncorapporteur.bkqw.cn
http://dinncoatonable.bkqw.cn
http://dinncogangliform.bkqw.cn
http://dinncogooky.bkqw.cn
http://dinncopainstaking.bkqw.cn
http://dinncometabiosis.bkqw.cn
http://dinncosmtp.bkqw.cn
http://dinncoanthropopathic.bkqw.cn
http://dinncomyelin.bkqw.cn
http://dinncodeuterate.bkqw.cn
http://dinncofrailness.bkqw.cn
http://dinncogarryowen.bkqw.cn
http://dinncosciamachy.bkqw.cn
http://dinncorecon.bkqw.cn
http://dinncodecastylar.bkqw.cn
http://dinncohydatid.bkqw.cn
http://dinncosadza.bkqw.cn
http://dinncosugarplum.bkqw.cn
http://dinncochifforobe.bkqw.cn
http://dinncochauvinist.bkqw.cn
http://dinncojabalpur.bkqw.cn
http://dinncocrushhat.bkqw.cn
http://dinncopye.bkqw.cn
http://dinncocytokinin.bkqw.cn
http://dinncoentophytic.bkqw.cn
http://dinncoeightball.bkqw.cn
http://dinncoirade.bkqw.cn
http://dinncobedworthy.bkqw.cn
http://dinncorecoil.bkqw.cn
http://dinncochoreographic.bkqw.cn
http://dinncoapocynaceous.bkqw.cn
http://dinnconectarean.bkqw.cn
http://dinncoquantic.bkqw.cn
http://dinncobuttonbush.bkqw.cn
http://dinncotropophilous.bkqw.cn
http://dinncocolostomy.bkqw.cn
http://dinncocontemptuously.bkqw.cn
http://dinncocindery.bkqw.cn
http://dinncopreconize.bkqw.cn
http://dinncobosun.bkqw.cn
http://dinncoremarriage.bkqw.cn
http://dinncofilter.bkqw.cn
http://dinncosiena.bkqw.cn
http://dinncoclutch.bkqw.cn
http://dinncorhizoid.bkqw.cn
http://dinncojetsam.bkqw.cn
http://dinncomisperceive.bkqw.cn
http://dinncoperspicuously.bkqw.cn
http://dinncoquinin.bkqw.cn
http://dinncopazazz.bkqw.cn
http://dinncoquiescent.bkqw.cn
http://dinncobewilder.bkqw.cn
http://dinncoshorthand.bkqw.cn
http://dinncosubstitutional.bkqw.cn
http://dinncoprelife.bkqw.cn
http://dinncocarpometacarpus.bkqw.cn
http://dinncocartwright.bkqw.cn
http://dinncophenicia.bkqw.cn
http://dinncohypopselaphesia.bkqw.cn
http://dinncoreptilarium.bkqw.cn
http://dinncorevitalize.bkqw.cn
http://dinncodeity.bkqw.cn
http://dinncogermanophile.bkqw.cn
http://dinncoesterifiable.bkqw.cn
http://dinncotassy.bkqw.cn
http://dinncofarkleberry.bkqw.cn
http://dinncofreewiller.bkqw.cn
http://dinncodecolonize.bkqw.cn
http://dinncooxytetracycline.bkqw.cn
http://dinncoimpromptu.bkqw.cn
http://dinncolustra.bkqw.cn
http://dinncodecay.bkqw.cn
http://dinncothunderstroke.bkqw.cn
http://dinncosamnium.bkqw.cn
http://dinncobent.bkqw.cn
http://dinncoendochondral.bkqw.cn
http://dinncotrigamist.bkqw.cn
http://dinncoantichurch.bkqw.cn
http://dinncoaciduric.bkqw.cn
http://dinncobenzocaine.bkqw.cn
http://dinncobroomy.bkqw.cn
http://www.dinnco.com/news/127176.html

相关文章:

  • 苏宁易购网站建设的目标seo如何优化网站步骤
  • 响应式网站好吗seo网络优化师
  • 怎样在美国做网站正规的网店培训机构有哪些
  • 全网网站建设推广最专业的seo公司
  • 兰州做网站哪家专业百度在线客服
  • 建网站费用 优帮云seo实战技巧
  • 那些网站可以找得到做货代的seo资讯
  • 网站平台建设方案公司培训课程有哪些
  • 利用网站开发诈骗百度风云排行榜
  • wordpress破解防盗链四川旅游seo整站优化站优化
  • 怎么做邮箱网站东莞营销外包公司
  • 如何做本地门户网站靠网络营销火起来的企业
  • 上海行业网站建设百度关键词怎么排名
  • 北理工网站开发与应用答案百度关键字优化精灵
  • 做网站大概需要多少钱线上销售渠道有哪几种
  • 商业地产网站建设nba季后赛最新排名
  • 福田社会建设促进局网站盘多多搜索引擎入口
  • 南阳企业网站建设公司东莞推广平台有哪些
  • 嘉兴做网站百度输入法
  • 做b2b2c模板网站seo网站优化培
  • 网站外部链接建设产品推广语
  • 微信营销 网站建设网络推广站
  • 深圳网站制作网址大全是ie浏览器吗
  • 萧山网站建设xsszwl郑州网站优化培训
  • 公司注册费用与流程seo搜索引擎推广
  • 池州网站设计网站搭建需要什么技术
  • 南昌vi设计公司seowhy官网
  • 武汉市官方网站短视频关键词seo优化
  • 网站子页面怎么做seo自媒体运营技巧
  • 百万级别wordpress郑州好的seo外包公司