![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法的复习
isonu
Talk is cheap,show me the code.
展开
-
字符串匹配(朴素查询+简单KMP)
字符串匹配问题在串一章中是最需要研究的问题,结合课本理论今天花了点时间写了字符串匹配的程序,分别用爆破和简单KMP实现了,下面直接上程序: 之后研究了网上的做法,发现绝大多数人都是用while来实现主要的KMP程序,但是这里我用了for循环。while更好理解而for有几处小细节需要注意,总之写程序边手写验证边写对我来说是最好的办法。KMP算法虽然程序看上去很简单,但是其中的复杂程度不低于树图类算法,其本质就是研究子串,或者更精确讲是研究子串的next数组。结合程序我认为大家需要思考的点有:为什么网上的原创 2022-06-05 00:28:27 · 247 阅读 · 1 评论 -
CTA-861标准解析EDID的VSDB与VDB
之前在某项目上做屏幕自适应分辨率时,按照vesa标准解析edid得出的分辨率不全导致自适应功能概率性失效,换为CTA 861标准解析后功能正常。此功能的代码对数据结构知识的要求不高,但是对C语言能力要求较高,特别是数位移、临界值的判断以及接口构建等操作。 花了一下午写了VSDB与VDB解析的接口,除了vic数组其余全部手码,代码如下: #include <stdio.h> //static int edid[] = { //0x00,0xff,0xff,0xff,0xff,0xff,0xf原创 2022-05-22 23:42:28 · 2858 阅读 · 0 评论 -
链栈实现括号匹配
睡前练手,欢迎纠错。实现计算机底层括号匹配功能。 #include <stdio.h> #include <string.h> #include <malloc.h> #define LEN 20 int flag; typedef struct Stack { char val; Stack* next; }Stack; int Initstack(Stack *&S) { S = (Stack*)malloc(sizeof(Stack)); .原创 2022-05-19 00:16:11 · 307 阅读 · 0 评论 -
规定大小的循环队列
#include <stdio.h> #define Maxsize 10 static bool flag = 0; static int det = 0; typedef struct Queue { int val[Maxsize]; int front, tail; }Queue; int initQueue(Queue& Q) { Q.front = Q.tail = 0; return 1; } int Enqueue(Queue& Q, int nu.原创 2022-05-15 20:30:15 · 295 阅读 · 0 评论 -
顺序表与链表实现双端队列与栈的增删
1.栈的增删与测试 #include <malloc.h> #include <stdio.h> #define Maxsize 10 /*顺序栈的数据结构定义*/ typedef struct { int data[Maxsize]; int top; }Stack; /*链表栈的数据结构*/ typedef struct Stacknode { int data; Stacknode* next; }Stacklist, Stacknode; /*初始化栈原创 2022-05-14 21:04:57 · 242 阅读 · 0 评论