11 2019 档案
摘要:new与make之间有什么不同? new 分配内存,make 初始化切片、映射和信道类型 如何获得方法的动态分配? 拥有动态分配方法的唯一途径就是通过接口。结构或其它混合类型的方法总是静态地确定 如何编写单元测试? 在相同的目录中创建一个以 结尾的新文件作为你的包源文件。 在该文件中,加入 并编写以
阅读全文
摘要:“类型”或“= 表达式”两个部分可以省略其中的一个。 如果省略的是类型信息,将根据初始化表达式来推导变量的类型信息。 如果初始化表达式被省略,将用零值初始化该变量。 数值类型变量对应的零值是0 布尔类型变量对应的零值是false 字符串类型对应的零值是空字符串(不是nil) 接口或引用类型(包括sl
阅读全文
摘要:拖延只会让你成为昨天的奴隶 狼道:格局有多大,事业就能做多高 如果少年多些努力,那么年老就会多点欣慰 得失就像椭圆上一点到两焦点的距离是定值,一边长了那么另一边肯定会短 别整天把自己幻想成悲剧主角,生活没那么多感情戏给你, 我出身不好,教养也差,但一直努力尝试做一个体面的人 如果你不努力工作,学习或
阅读全文
摘要:```c /* Author: Zoro Date: 2019/11/10 Function: Valid Anagram Title: leetcode 242 anagram.c think: 桶排序思想 */ #include #include #include bool isAnagram(char *s, char *t) { int statS[26] = {0}; int statT
阅读全文
摘要:```c /* Author: Zoro Date: 2019/11/10 Function: Majority Element Title: leetcode 169 think: 出现的次数最多,且大于数组的二分之一 两种方法:统计方法,数据结构法 1: 空 入栈 2: 栈顶 = 元素 入栈 3: 其它情况 出栈 majority.c 时间复杂度: O(n) 空间复杂度: O(n) */ #i
阅读全文
摘要:```c /* quicksort.c Author: Zoro Date: 2019/11/8 function: 快速排序 QuickSort pivot partition */ #include void quickSort(int arr[], int L, int R) { int i = L; int j = R; int pivot = arr[(L + R) / 2]; whil
阅读全文
摘要:```c/*Insertion SortAuthor: ZoroDate: 2019/11/7function: 插入排序*/#include void insert(int arr[], int n) { int key = arr[n]; int i = n; while (arr[i-1] > key) { arr[i] = arr[i-1]; ...
阅读全文
摘要:```c /* Selection Sort Writed by Zoro Date: 2019/11/7 function:选择排序 3 7 4 2 6 1 3 1 4 2 6 7 3 1 4 2 6 7 3 1 2 4 6 7 1 2 3 4 6 7 */ #include int findMaxPos(int arr[], int n) { int max = arr[0]; int pos
阅读全文
摘要:```c/*bubble.cwrite by Zorodate: 2019/11/7function: 冒泡排序*/#include void bubble(int arr[], int n) { int i; int tmp; for (i = 0; i arr[i+1]) { tmp = arr[i]; arr[i] = arr[...
阅读全文