- 博客(4)
- 收藏
- 关注
原创 数据结构书上kmp算法代码实现
本人用的是清华大学严蔚敏教授编写的数据结构教材,利用代码实现kmp算法/*KMP算法 数据结构书上版代码实现*/#include <stdio.h>#include <math.h>#include <string.h>int main(void){ int next[128]; next[0]=-1; /*next[0]为特殊位置,因为字符串0位置不存在公共前后缀,标记为-1*/ char T[128]; char S[128]; int
2021-10-24 17:06:07
247
原创 KMP算法通俗易懂版
/*KMP算法*/#include <stdio.h>#include <math.h>#include <string.h>int main(void){ int next[128]; next[0]=0; char T[128]; char S[128]; int i,j,lenT,lenS; printf("请输入主串:"); gets(T); printf("请输入模式串:"); gets(S); i=1; j=0.
2021-10-21 15:55:25
110
原创 已知带头结点的动态单链表L中的结点是按整数值递增排列的,试写一算法将值x为的结点插入到表L中,使L仍然有序。
创建链表,main函数中通过while循环找出该插入的位置,插入。应注意L头节点位置的变化,利用一个ptr来记录L的头节点。/*已知带头结点的动态单链表L中的结点是按整数值递增排列的,试写一算法将值x为的结点插入到表L中,使L仍然有序。*/#include <stdio.h>#include <stdlib.h>#include <malloc.h>#include <math.h>#define OK 1;typedef int s
2021-10-16 21:24:53
4948
1
原创 已知L为非递减的顺序表,请设计算法删除L中重复的元素(即删除后使L表变为一递增表)。
#include <stdio.h>#include <stdlib.h>#define OK 1;typedef int status;typedef int ElemType;typedef struct{ ElemType *elem; int length; int listlize;}SqList;status InitList(SqList *L,int len) /*顺序表的创建*/{ L->...
2021-10-16 16:03:20
866
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人