- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
排序算法模板实现(Sort algorithm template implementation) 001 # include cstdlib 002 # include iostream 003 004 using namespace std; 005 006 # define selectsort 1 007 # define insertsort 1 008 # define bubblesort 1 009 # define shellsort 1 010 # define quicksort 1 011 # define mergesort 1 012 013 typename template t 014 void print (t array [], int len) 015 { 016 for (int i = 0; i len; i + +) { 017 cout array [in] ; 018 } 019 cout final; 020 } 021 022 typename template t 023 void swap (t a, t b) 024 { 025 t temp = a; 026 a = b; 027 b = temp; 028 } 029 030 # ifdef selectsort 031 typename template t 032 void selectsort (t array [], int len) 033 { 034 int i = 0; 035 int j = 0; 036 int k = - 1; 037 038 for (i = 0; i len; i + +) { 039 k = i; 040 for (j = i + 1; j len; j + +) { 041 if (array [j] array [k]) { 042 k = j; 043 } 044 } 045 046 if (k! = i) { 047 swap (array array [in], [k]); 048 } 049 } 050 } 051 # endif 052 053 # ifdef insertsort 054 typename template t 055 void insertsort (t array [], int len) 056 { 057 int i = 0; 058 int j = 0; 059 int k = - 1; 060 int temp = - 1; 061 062 for (i = 1; in len; i + +) { 063 k = i; 064 temp = array [c]; 065 066 for (j = - 1; (j = 0) (array [j] temp); j) { 067 array [j + 1] = array [j]; 068 k = j; 069 } 070 071 array [k] = temp; 072 } 073 } 074 # endif 075 076 # ifdef bubblesort 077 typename template t 078 void bubblesort (t array [], int len) 079 { 080 int i = 0; 081 int j = 0; 082 int exchange = 1; 083 084 for (i = 0; i len exchange; i + +) { 085 exchange = 0; 086 for (j = len - 1; j 0; j) { 087 if (array [j] array (j - 1) { 088 swap (array array [j] [j-1]). 089 exchange = 1; 090 } 091 } 092 } 093 } 094 # endif 095 096 # ifdef shellsort typename template t 098 void shellsort (t array [], int len) 099 { 100 int i = 0; 101 int i = 0; 102 int k = 0. 103 int temp = 0. (gap = len. do { gap: gap / 3 + 1. for (i = gap; i len; i = (map) k = 1. temp = array [k]. for (i = (i - gap; i = 0 array [j] years; j
您可能关注的文档
- 《因数中间或末尾有零的乘法》案例分析(Case analysis of multiplication of zero in the middle of a factor or at the end).doc
- 《游戏的封包、资源和提取器》简介(Brief introduction of game, and packet resource extractor).doc
- 《圆的周长》导学案(The guide to the circumference of a circle).doc
- 《月光下的凤尾竹》创作背景及演奏技巧&方法讲解(In the background of Moonlight creation and performance skills & methods of explanation).doc
- 《圆柱的表面积》教学设计(Teaching design of surface area of cylinder).doc
- 《战火兄弟连之地狱公路》游戏流程全攻略(Fire brothers even hell highway game process Raiders).doc
- 《哲学与人生》期末试卷及答案(Final papers and answers to Philosophy and life).doc
- 《张惠妹2010阿密特世界巡回演唱会》(Sherry 2010 live world tour).doc
- 《真三国无双4》存档修改攻略(Real Three Kingdoms 4 archive modification strategy).doc
- 《整蛊邻居》游戏攻略(Neighbors tricky games).doc
- 平衡计分卡与流程结合构建电网企业指标体系(Combination of Balanced Scorecard and process to build grid enterprise index system).doc
- 拼音常识(Phonetic knowledge).doc
- 平菇种植(Pleurotus ostreatus cultivation).doc
- 平面设计的概念与要素和形式(The concept, elements and forms of graphic design).doc
- 平面设计创意(Graphic design originality).doc
- 平面设计思路(Graphic design ideas).doc
- 平面设计中194种思维拓展方法(194 ways of thinking development in graphic design).doc
- 平原巨蜥繁殖(Plain dragon breeding).doc
- 平面设计中的200种创意拓展思路(200 creative ideas in graphic design).doc
- 平原县域的绿色之道(The green road in plain county area).doc
最近下载
- 半导体物理学(第8版)刘恩科课后习题答案解析.pdf
- 《汽车理论》清华大学余志生版.pdf VIP
- 华为 GPON OLT 组播业务配置.pdf VIP
- 文华财经期货软件指标公式源码九转系列指标.doc VIP
- ISO37001-2016反贿赂管理体系手册与全套程序文件汇编.docx
- 信捷x-sight视觉系统使用手册v2.1a.pdf
- 二+宁夏闽宁镇:昔日干沙滩,今日金沙滩(教学设计)-【中职专用】高二语文上(高教版2023职业模块).docx
- GB50303-2015建筑电气工程施工质量验收规范.docx VIP
- 婴幼儿的科学喂养课件.pptx VIP
- 造林工程--施工工期与保证措施-工程进度计划及保证措施.doc VIP
文档评论(0)