2022年2月25日
摘要: #include <stdio.h> int main() { FILE *fp; FILE *from; char ch; char p[20]="hello"; fp = fopen("test.c","r+"); from =fopen("copy2.c","w+"); if((fp=fope 阅读全文
posted @ 2022-02-25 19:42 慧茗子 阅读(21) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #define MAX 100 int read_line(int fd, char *buf 阅读全文
posted @ 2022-02-25 16:10 慧茗子 阅读(19) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <errno.h> #define BUF 阅读全文
posted @ 2022-02-25 15:08 慧茗子 阅读(31) 评论(0) 推荐(0)
  2022年2月23日
摘要: 一、Linux系统调用及用户编程接口(API) errno(error+number)——错误代码,自动赋值 当linux中的 api函数发生异常时,一般会将errno变量(需include errno.h)赋一个整数值,不同的值表示不同的含义,可以通过查看该值推测出错的原因 1、系统调用 操作系统 阅读全文
posted @ 2022-02-23 21:37 慧茗子 阅读(29) 评论(0) 推荐(0)
摘要: 一、概述 1、定义 将文件中的数据记录按关键字值的递增或递减的顺序排列起来。 {R1, R2,..., Rn}→ {Ri1, Ri2,..., Rin} 其中关键字{k1, k2,..., kn}→有序序列{ki1, ki2,..., kin} 2、排序方法的稳定性: 对于ki=kj的记录Ri=Rj 阅读全文
posted @ 2022-02-23 21:37 慧茗子 阅读(49) 评论(0) 推荐(0)
摘要: 哈希函数就是根据key计算出应该存储地址的位置,而哈希表是基于哈希函数建立的一种查找表。 一、哈希函数 1、构造方法 (1)直接定址法 哈希函数为关键字的线性函数如H (key ) =a.key+b或H(key)=key;适应情况:事先知道关键码,关键码集合不是很大且连续性较好;优点:不会产生冲突缺 阅读全文
posted @ 2022-02-23 21:36 慧茗子 阅读(151) 评论(0) 推荐(0)
  2022年2月19日
摘要: 一、栈以及相关操作 1、定义 只允许在一端插入和删除的线性表; 允许插入和删除的一端称为栈顶(top),另一端称为栈底(bottom)。 2、特点 后进先出(LIFO) 3、主要操作 ADT Stack //对象:由数据类型为StackData的元素构成 { int Push (stack *S, 阅读全文
posted @ 2022-02-19 21:39 慧茗子 阅读(22) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #define SIZE 10 #define MALLOC_OK 1 #define MALLOC_NO 0 #define CREATE_OK 1 #define CREATE_NO 0 enum ret_val{FU 阅读全文
posted @ 2022-02-19 15:41 慧茗子 阅读(28) 评论(0) 推荐(0)
  2022年2月18日
摘要: 完整代码 #include <stdio.h> #include <stdlib.h> #define CREATE_OK 0 #define CREATE_NO 1 #define MALLOC_OK 0 #define MALLOC_NO 1 #define EMPTY_OK 0 #define 阅读全文
posted @ 2022-02-18 23:37 慧茗子 阅读(19) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #define CREATE_OK 0 #define CREATE_NO 1 #define MALLOC_OK 0 #define MALLOC_NO 1 #define EMPTY_OK 0 #define EMPT 阅读全文
posted @ 2022-02-18 23:36 慧茗子 阅读(24) 评论(0) 推荐(0)