2019年5月8日

C:选择排序

摘要: 选择排序的思想是每一次遍历数组,将最大的值与最右边值作交换,之后len减1,依次交换之后排序结束 #include <stdio.h>#include <stdlib.h>int max(int a[], int right){ int i,j; int maxid = 0; for (i = 1; 阅读全文

posted @ 2019-05-08 19:05 zhaoy_shine 阅读(346) 评论(0) 推荐(0) 编辑

C:数组的要点和技巧

摘要: 技巧: 1.数组的初始化 两种方法 (1) for (i = 0; i < 10; i++) { cout[i] = 0; } (2) cout[ ] = {0} 2.对于零散的数组中值的赋值 cout[ ] = {[1] =2, 4,[5]=6 } 输出为 0 2 4 0 0 6 3.search 阅读全文

posted @ 2019-05-08 19:05 zhaoy_shine 阅读(145) 评论(0) 推荐(0) 编辑

C:折半查找法(二分法)

摘要: 主要用于已经做了排序的数字,时间复杂度:log2n 直接贴代码 #include <stdio.h>#include <stdlib.h>int search(int search_num, int a[], int right){ int left = 0; int ret = -1; int m 阅读全文

posted @ 2019-05-08 17:38 zhaoy_shine 阅读(265) 评论(0) 推荐(0) 编辑

导航