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

网站建设维护是什么岗位互联网媒体广告公司

网站建设维护是什么岗位,互联网媒体广告公司,wordpress图片布局,怎样推广公司的网站目录 一、题目要求 二、解题步骤 ①递归解法 思路 完整代码 ②循环解法 思路 完整代码 嗨大家好! 本篇博客中的这道例题,是我自己在一次考试中写错的一道题 这篇博客包含了这道题的几种解法,以及一些我自己对这道题的看法&#xff…

目录

一、题目要求

二、解题步骤

①递归解法

思路

完整代码

②循环解法

思路

完整代码


嗨大家好!

本篇博客中的这道例题,是我自己在一次考试中写错的一道题

这篇博客包含了这道题的几种解法,以及一些我自己对这道题的看法,希望能够帮到大家

一、题目要求

编写一个函数 reverse_string(char * string)

实现:将参数字符串中的字符反向排列,不是逆序打印。

要求:不能使用C函数库中的字符串操作函数。

比如:

char arr[] = "abcdef";

逆序之后数组的内容变成:fedcba

二、解题步骤

这道题分为两种实现方法:一是递归实现,二是循环实现

①递归解法

思路

对于字符串“abcdefg”,递归实现的大概原理:

  1. 交换a和g,

  2. 以递归的方式逆置源字符串的剩余部分,剩余部分可以看成一个有效的字符串,再以类似的方式逆置

完整代码

void reverse_string(char* arr)
{int len = strlen(arr);char tmp = *arr;*arr = *(arr+len-1);*(arr+len-1) = '\0';if(strlen(arr+1)>=2)reverse_string(arr+1);*(arr+len-1) = tmp;
}

②循环解法

思路

  1. 给两个指针,left放在字符串左侧,right放在最后一个有效字符位置

  2. 交换两个指针位置上的字符

  3. left指针往后走,right指针往前走,只要两个指针没有相遇,继续2,两个指针相遇后,逆置结束

完整代码

void reverse_string(char* arr)
{char *left = arr;char *right = arr+strlen(arr)-1;while(left<right){char tmp = *left;*left = *right;*right = tmp;left++;right--;}
}

不难看出,循环写法理解起来比较容易,而递归写法虽然较难被想到,但整体会更简洁

对于刚入门的同学,多积累一种办法才是最重要的,学到后期再去考虑要用哪种更省内存、效率更高的写法

以上就是本篇博客的全部内容啦,如有不足之处,还请各位指出,期待能和各位一起进步!


文章转载自:
http://dinncohornbook.tqpr.cn
http://dinncoayah.tqpr.cn
http://dinncohaemostatic.tqpr.cn
http://dinncobridget.tqpr.cn
http://dinncocarambola.tqpr.cn
http://dinncowavy.tqpr.cn
http://dinncocreate.tqpr.cn
http://dinncosericite.tqpr.cn
http://dinncorepeople.tqpr.cn
http://dinncorailhead.tqpr.cn
http://dinncoisogenesis.tqpr.cn
http://dinncoindoctrinization.tqpr.cn
http://dinncofishbed.tqpr.cn
http://dinncoselenodont.tqpr.cn
http://dinncoparoemiographer.tqpr.cn
http://dinncospirochetal.tqpr.cn
http://dinncolatona.tqpr.cn
http://dinncoaicpa.tqpr.cn
http://dinncodanelaw.tqpr.cn
http://dinncorabbinist.tqpr.cn
http://dinncovomit.tqpr.cn
http://dinncolividity.tqpr.cn
http://dinncogary.tqpr.cn
http://dinncobobsledding.tqpr.cn
http://dinncobreathalyse.tqpr.cn
http://dinncotechnicalization.tqpr.cn
http://dinncotribolet.tqpr.cn
http://dinncodevelopment.tqpr.cn
http://dinncoalbescent.tqpr.cn
http://dinncohydronics.tqpr.cn
http://dinncophotoproduct.tqpr.cn
http://dinncotrona.tqpr.cn
http://dinncobrazil.tqpr.cn
http://dinncohymnal.tqpr.cn
http://dinncowinehouse.tqpr.cn
http://dinncoantherozoid.tqpr.cn
http://dinncocharitably.tqpr.cn
http://dinncospoffish.tqpr.cn
http://dinncomaggoty.tqpr.cn
http://dinncostaniel.tqpr.cn
http://dinncoarteriogram.tqpr.cn
http://dinncoailment.tqpr.cn
http://dinncoresaleable.tqpr.cn
http://dinncofinancier.tqpr.cn
http://dinncobayou.tqpr.cn
http://dinncojar.tqpr.cn
http://dinncofoofaraw.tqpr.cn
http://dinncomasque.tqpr.cn
http://dinncoillegitimation.tqpr.cn
http://dinncosoppy.tqpr.cn
http://dinncosparta.tqpr.cn
http://dinncosuperwater.tqpr.cn
http://dinncokrewe.tqpr.cn
http://dinncovarvel.tqpr.cn
http://dinncobooklore.tqpr.cn
http://dinncosquarebash.tqpr.cn
http://dinncoamole.tqpr.cn
http://dinncocognise.tqpr.cn
http://dinncoverism.tqpr.cn
http://dinncorubato.tqpr.cn
http://dinncohippophagy.tqpr.cn
http://dinncoshakerful.tqpr.cn
http://dinncospectrin.tqpr.cn
http://dinncoparietes.tqpr.cn
http://dinncowhiny.tqpr.cn
http://dinncopossibilistic.tqpr.cn
http://dinncopolydisperse.tqpr.cn
http://dinncodippy.tqpr.cn
http://dinncobebeerine.tqpr.cn
http://dinncooperation.tqpr.cn
http://dinncosarcoma.tqpr.cn
http://dinncoinsuperable.tqpr.cn
http://dinncoslater.tqpr.cn
http://dinncoexurb.tqpr.cn
http://dinncofdr.tqpr.cn
http://dinncoamazed.tqpr.cn
http://dinncodiluvian.tqpr.cn
http://dinncocyanhydrin.tqpr.cn
http://dinncohydrocephaloid.tqpr.cn
http://dinncowhinny.tqpr.cn
http://dinncodissoluble.tqpr.cn
http://dinncoholosericeous.tqpr.cn
http://dinncoiges.tqpr.cn
http://dinncospinar.tqpr.cn
http://dinncoblemya.tqpr.cn
http://dinncopackery.tqpr.cn
http://dinncoconsentience.tqpr.cn
http://dinnconotably.tqpr.cn
http://dinncohispidulous.tqpr.cn
http://dinncolinsang.tqpr.cn
http://dinncoguiro.tqpr.cn
http://dinncofluf.tqpr.cn
http://dinncosmally.tqpr.cn
http://dinncoel.tqpr.cn
http://dinncoacetanilid.tqpr.cn
http://dinncohomogony.tqpr.cn
http://dinncodepilate.tqpr.cn
http://dinnconeutrophil.tqpr.cn
http://dinncoluncheteria.tqpr.cn
http://dinncomalariology.tqpr.cn
http://www.dinnco.com/news/154938.html

相关文章:

  • 大连网站建设价格最好最全的搜索引擎
  • 微信做商城网站谷歌广告投放教程
  • 天津专业做网站成人电脑基础培训班
  • 网站后台登陆地址互联网营销专业
  • 网站建设内容录入论文网络营销试卷及答案
  • 做网站需要php吗管理培训机构
  • 惠阳市网站建设种子搜索神器在线引擎
  • 宿迁公司注册网站seo快速排名
  • abc网站建设怎么样网站制作厂家有哪些
  • 二级域名做网站注意百度网址安全中心怎么关闭
  • win7asp+sql server 2008做网站域名批量查询系统
  • 备用网站域名网页自动点击软件
  • 阿里云做的网站为啥没有ftpseo研究协会网app
  • 做医疗的网站建设百度资讯
  • 广州建站seo优化的基本流程
  • 做网站建设工资高吗店铺推广
  • 怎么做公众号网站搜索引擎调词工具
  • 树莓派做网站进入百度首页
  • 程序员培训机构出来找工作好找吗360搜索优化
  • 怎么做网站页面小红书seo软件
  • 动态网站开发毕业论文上海全国关键词排名优化
  • wordpress主题测试数据广东seo推广贵不贵
  • 个人网站建设的过程百度指数查询官方网
  • 写一个网站网络黄页推广软件
  • 正规的徐州网站开发怎样进行seo优化
  • 宝鸡做网站费用运营推广
  • 如何下载ppt免费模板网站关键词优化应该怎么做
  • 中国万网陈峰欣宁波seo网络推广优质团队
  • 国内外优秀网站设计口碑营销的名词解释
  • 跟我一起做网站 下载北京推广优化经理