摘要:
malloc: void *malloc ( size_t size ): 返回指向该内存的指针,若无法获取,则会返回NULL,故使用 malloc 要检查! calloc:void *calloc ( size_t num_elements, size_t element_size ); clea 阅读全文
摘要:
数组: 只有初始化定义才能 arr = { 0 }; memset(a,0,sizeof(a)); 是中途清零的方法。 结构体: typedef struct namex { }name; 会创建一个name类型的结构体,也可用name进行类型定义,但是不可以定义指针,仍需要用struct name 阅读全文
摘要:
Method 1: 采用二进制编码以表示是否出现在集合里。 #include <stdio.h> #include <string.h> #include <math.h> void fun(int num, int bin[]) { ///十进制转化二进制 int i = 0,j; for (j 阅读全文
摘要:
bubble_sort 比较次数是由数组长度决定,时间会比较长。 void bubble_sort(int arr[], int len) { int i, j, temp; for(i=0; i<len-1; i++) for(j=0; j<len-i-1; j++) if (arr[j] > a 阅读全文