全部评论(1条)
-
- 2yulaosan 2016-03-12 00:00:00
- #include <stdlib.h> #include <stdio.h> void Merge(int sourceArr[],int tempArr[], int startIndex, int midIndex, int endIndex) { int i = startIndex, j=midIndex+1, k = startIndex; while(i!=midIndex+1 && j!=endIndex+1) { if(sourceArr[i] >= sourceArr[j]) tempArr[k++] = sourceArr[j++]; else tempArr[k++] = sourceArr[i++]; } while(i != midIndex+1) tempArr[k++] = sourceArr[i++]; while(j != endIndex+1) tempArr[k++] = sourceArr[j++]; for(i=startIndex; i<=endIndex; i++) sourceArr[i] = tempArr[i]; } //内部使用递归 void MergeSort(int sourceArr[], int tempArr[], int startIndex, int endIndex) { int midIndex; if(startIndex < endIndex) { midIndex = (startIndex + endIndex) / 2; MergeSort(sourceArr, tempArr, startIndex, midIndex); MergeSort(sourceArr, tempArr, midIndex+1, endIndex); Merge(sourceArr, tempArr, startIndex, midIndex, endIndex); } } int main(int argc, char * argv[]) { int a[8] = {50, 10, 20, 30, 70, 40, 80, 60}; int i, b[8]; MergeSort(a, b, 0, 7); for(i=0; i<8; i++) printf("%d ", a[i]); printf("\n"); return 0; }
-
赞(7)
回复(0)
热门问答
- 三菱编程软件为什么查看帮助要联网
2016-03-11 19:30:57
386
1
- 三菱编程软件GXDeveloper为什么无法仿真
2010-06-12 01:18:15
349
4
- 关于三菱编程软件GX developer 软元件内存查看的问题
- 在梯形图逻辑测试里(就是软件模拟运行程序),能看软元件D0里的值吗? 应该怎样做? 程序对D0进行了赋值,然后在却看不到,求高手指教,不胜感激!!!
2013-08-29 16:33:19
287
1
- 三菱触摸屏编程软件!
- 哪里可以下载三菱触摸屏编程软件啊!哪位大师有能发一个吗?感谢!
2015-08-27 20:48:06
338
1
- 三菱编程软件字体颜色
2018-11-27 03:34:11
461
0
- 三菱fx1N编程软件下载
- 那个大哥有三菱FX1N-60MR-ES/UL的编程软件啊!有的 请帮忙发送给我哈!谢谢!我的Email:ctsujun888@126.com
2009-12-14 04:27:53
347
2
- 三菱编程软件怎么安装
2017-11-28 09:54:34
414
1
- 三菱FX3SA编程软件是什么?
- 三菱FX3SA编程软件是什么?一般的三菱编程软件没有3s型号。求解,谢谢。
2015-04-26 07:03:49
904
1
- 三菱编程软件 库操作 为什么不能新建库?
2017-02-28 18:05:31
411
2
- 为什么我装的三菱PLC编程软件打不开
2016-12-28 05:37:42
487
1
- 三菱plcFX-on下载哪一个编程软件
2017-03-29 00:39:16
447
2
- win8怎么安装三菱编程软件
2014-10-01 07:09:07
445
3
- 三菱plc编程软件加速时间
- 三菱plc编程软件加速时间
2017-08-17 08:46:54
291
1
- 启动三菱PLC编程软件错误
- 当启动三菱PLCGX DEVELOPER 8.86版本时,出现Can not allocate share memory,请问下是什么原因?
2010-12-06 05:44:13
243
6
- 三菱PLC编程软件怎么下载
2018-06-18 15:51:30
317
1
- 三菱PLC编程软件叫什么名字?
2009-02-15 05:59:45
248
3
- 为什么我的电脑不能安装三菱PLC编程软件
2013-10-26 16:11:53
601
3
- 使用电子天平时,为什么要经常查看水平仪
- 使用电子天平时,为什么要经常查看水平仪... 使用电子天平时,为什么要经常查看水平仪 展开
2016-11-13 09:21:23
646
2
- 三菱运动控制器编程软件MT-Developer通讯出现问题
- 这两个问题一个是无法通讯另一个是无法运行哪几个软件... 这两个问题一个是无法通讯另一个是无法运行哪几个软件 展开
2013-08-28 03:08:57
343
2
- 三菱plc编程软件8.52怎么安装
2017-10-18 11:16:32
385
2
9月突出贡献榜
- 单位预算忏悔
- 饿啊地方
- 空中有牛
- 依然相信你会
- 本生(天津)健康科技有限公司
- 猫合宝
- 武汉安德信检测设备有限公司
- 上海一科仪器有限公司
- 广东皓天检测仪器有限公司
- 东莞市皓天试验设备有限公司
- futu888
- 牛牛麻麻2
推荐主页
最新话题
参与评论
登录后参与评论