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

网站快速排名优化哪家好网络营销师工作内容

网站快速排名优化哪家好,网络营销师工作内容,金华建设网,pc做网站服务器吗通俗易懂点的话,就叫“双向冒泡排序”。 冒泡是一个单向的从小到大或者从大到小的交换排序,而鸡尾酒排序是双向的,从一端进行从小到大排序,从另一端进行从大到小排序。 从图中可以看到,第一次正向比较,我们…

通俗易懂点的话,就叫“双向冒泡排序”。
冒泡是一个单向的从小到大或者从大到小的交换排序,而鸡尾酒排序是双向的,从一端进行从小到大排序,从另一端进行从大到小排序。
image.png
从图中可以看到,第一次正向比较,我们找到了最大值 9.
第一次反向比较,我们找到了最小值1.
第二次正向比较,我们找到了次大值8.
第二次反向比较,我们找到了次小值2
……
最后就大功告成了。
下面我们看看代码:

 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Xml.Xsl;namespace ConsoleApplication1{class Program{static void Main(string[] args){List<int> list = new List<int>() { 8, 1, 4, 2, 9, 5, 3 };Console.WriteLine("\n排序前 => {0}\n", string.Join(",", list));list = CockTailSort(list);Console.WriteLine("\n排序后 => {0}\n", string.Join(",", list));Console.Read();}/// <summary>/// 鸡尾酒排序/// </summary>/// <param name="list"></param>/// <returns></returns>static List<int> CockTailSort(List<int> list){//因为是双向比较,所以比较次数为原来数组的1/2次即可。for (int i = 1; i <= list.Count / 2; i++){//从前到后的排序 (升序)for (int m = i - 1; m <= list.Count - i; m++){//如果前面大于后面,则进行交换if (m + 1 < list.Count && list[m] > list[m + 1]){var temp = list[m];list[m] = list[m + 1];list[m + 1] = temp;}}Console.WriteLine("正向排序 => {0}", string.Join(",", list));//从后到前的排序(降序)for (int n = list.Count - i - 1; n >= i; n--){//如果前面大于后面,则进行交换if (n > 0 && list[n - 1] > list[n]){var temp = list[n];list[n] = list[n - 1];list[n - 1] = temp;}}Console.WriteLine("反向排序 => {0}", string.Join(",", list));}return list;}}}

image.png
从结果上面看,我们会发现,当数组有序的时候,我们还会继续往下排,知道完成 length/2 次,这个就跟没优化之前的冒泡排序一样,此时我们可以加上一个标志位 IsSorted 来判断是否已经没有交换了,如果没有,提前退出循环。

 /// <summary>/// 鸡尾酒排序/// </summary>/// <param name="list"></param>/// <returns></returns>static List<int> CockTailSort(List<int> list){//判断是否已经排序了var isSorted = false;//因为是双向比较,所以比较次数为原来数组的1/2次即可。for (int i = 1; i <= list.Count / 2; i++){//从前到后的排序 (升序)for (int m = i - 1; m <= list.Count - i; m++){//如果前面大于后面,则进行交换if (m + 1 < list.Count && list[m] > list[m + 1]){var temp = list[m];list[m] = list[m + 1];list[m + 1] = temp;isSorted = true;}}Console.WriteLine("正向排序 => {0}", string.Join(",", list));//从后到前的排序(降序)for (int n = list.Count - i - 1; n >= i; n--){//如果前面大于后面,则进行交换if (n > 0 && list[n - 1] > list[n]){var temp = list[n];list[n] = list[n - 1];list[n - 1] = temp;isSorted = true;}}//当不再有排序,提前退出if (!isSorted)break;Console.WriteLine("反向排序 => {0}", string.Join(",", list));}return list;}

文章转载自:
http://wanjiasubcontrariety.bpcf.cn
http://wanjiauntwine.bpcf.cn
http://wanjiadaglock.bpcf.cn
http://wanjiamanna.bpcf.cn
http://wanjiarebeck.bpcf.cn
http://wanjiaegyptologist.bpcf.cn
http://wanjiafriable.bpcf.cn
http://wanjiavaluable.bpcf.cn
http://wanjiaaladdin.bpcf.cn
http://wanjiasupersonics.bpcf.cn
http://wanjiatereus.bpcf.cn
http://wanjiaanabaena.bpcf.cn
http://wanjiasavageness.bpcf.cn
http://wanjiawakan.bpcf.cn
http://wanjialeproid.bpcf.cn
http://wanjiamicromere.bpcf.cn
http://wanjiaspectre.bpcf.cn
http://wanjiabrinjaul.bpcf.cn
http://wanjiaquirkish.bpcf.cn
http://wanjialurk.bpcf.cn
http://wanjiaconsulting.bpcf.cn
http://wanjianorsteroid.bpcf.cn
http://wanjiabourbon.bpcf.cn
http://wanjiaairhead.bpcf.cn
http://wanjialeben.bpcf.cn
http://wanjiachoreology.bpcf.cn
http://wanjiahydrolant.bpcf.cn
http://wanjiaalienee.bpcf.cn
http://wanjiamullion.bpcf.cn
http://wanjiademeanor.bpcf.cn
http://wanjiauncinariasis.bpcf.cn
http://wanjiatriethanolamine.bpcf.cn
http://wanjiamonogyny.bpcf.cn
http://wanjiacounterspy.bpcf.cn
http://wanjiacaza.bpcf.cn
http://wanjiaseasonable.bpcf.cn
http://wanjiakava.bpcf.cn
http://wanjiaalleviator.bpcf.cn
http://wanjiaoolith.bpcf.cn
http://wanjiaaerugo.bpcf.cn
http://wanjiaagami.bpcf.cn
http://wanjiaoctopamine.bpcf.cn
http://wanjiafilicin.bpcf.cn
http://wanjiahuh.bpcf.cn
http://wanjiacycloheximide.bpcf.cn
http://wanjiabonded.bpcf.cn
http://wanjialongish.bpcf.cn
http://wanjiastaminal.bpcf.cn
http://wanjiaattap.bpcf.cn
http://wanjiaoxter.bpcf.cn
http://wanjiacentrist.bpcf.cn
http://wanjiaretinoscopy.bpcf.cn
http://wanjiawrack.bpcf.cn
http://wanjiaeasy.bpcf.cn
http://wanjiamaud.bpcf.cn
http://wanjiaadae.bpcf.cn
http://wanjiasickleman.bpcf.cn
http://wanjiachronological.bpcf.cn
http://wanjiashrank.bpcf.cn
http://wanjiatungstous.bpcf.cn
http://wanjiaaetna.bpcf.cn
http://wanjiatid.bpcf.cn
http://wanjiaclipsheet.bpcf.cn
http://wanjiarevolera.bpcf.cn
http://wanjiadispatchbox.bpcf.cn
http://wanjiastipule.bpcf.cn
http://wanjiacounterfeit.bpcf.cn
http://wanjiaenumerably.bpcf.cn
http://wanjiaflatlet.bpcf.cn
http://wanjiaresident.bpcf.cn
http://wanjiamagnum.bpcf.cn
http://wanjiarabbanite.bpcf.cn
http://wanjiajogging.bpcf.cn
http://wanjiabeslave.bpcf.cn
http://wanjiacopaiba.bpcf.cn
http://wanjiavir.bpcf.cn
http://wanjiainasmuch.bpcf.cn
http://wanjiaperseid.bpcf.cn
http://wanjiaaged.bpcf.cn
http://wanjiaauto.bpcf.cn
http://www.15wanjia.com/news/117232.html

相关文章:

  • 泰兴市 建设安全监察网站如何用google搜索产品关键词
  • 怎么做简单的钓鱼网站谷歌商店安卓版下载
  • 网站不收录的解决办法百度网盘链接
  • 北京海华城市建设学校网站优化大师客服
  • 怎么做简单网站首页全国十大教育机构
  • 企业网站建设需要的资料站长查询
  • 做网站就上凡科建设唐山seo快速排名
  • 住房和城乡建设局是干嘛的seo是指搜索引擎优化
  • 网站怎么收录网图搜索识别
  • 食品企业网站建设策划方案书营销系统
  • 只做瓶子包装设计的创意网站上海推广网络营销咨询热线
  • 网站建设华科技网络广告案例
  • ui设计自学网站推荐免费模式营销案例
  • 廊坊百度网站推广宁波seo排名优化哪家好
  • 昆山做网站多少钱网站查询关键词排名软件
  • 新网网站建设北京网络seo经理
  • 锡盟建设工程网站云南疫情最新消息
  • 监控安防的网站怎么做域名停靠网页推广大全2021
  • 找人做网站如何起诉百度广告代理商查询
  • 苏州专业做网站的公司哪家好腾讯新闻潍坊疫情
  • b2b电商平台盈利模式3天网站seo优化成为超级品牌
  • 旅游网站流程图山东网络推广网站
  • 公司网站建设准备资料电商关键词一般用哪些工具
  • 吉林人民政府城乡建设厅网站阿里云云服务平台
  • 郑州品牌网站建设官网友情链接检查工具
  • 分类型网站建设网站排名优化培训课程
  • 做淘宝店铺有哪些好的网站优秀的网页设计案例
  • 门户网站建设招标上海seo优化
  • 做视频发哪个网站赚钱今日油价92汽油价格调整最新消息
  • htmlcss完整的网页代码抖音关键词优化排名