数据结构实验三实验报告(4)
时间:2025-07-11
时间:2025-07-11
数据结构实验报告
return 0;
}
else
{
for(i=pos+len; i<=S->length-1; i++)
S->str[i-len]=S->str[i];
S->length=S->length-len;
return 1;
}
}
int SubString(String S, int pos, int len, String *T)
{
int i;
if(pos<0||len<0||pos+len>S.length)
{
printf("The parameters pos and len are not correct!\n");
return 0;
}
else
{
for(i=0; i<=len; i++)
T->str[i]=S.str[pos+i];
T->length=len;
return 1;
}
}
/*BFcomKMP.c*/
#include<stdio.h>
#define MaxSize 100
#include"SString.h"
#include"BFandKMP.h"
void main(void)
{
String S1={{"cddcdc"},6}, T1={{"abcde"},5};
String S2={{"aaaaaaaa"},8}, T2={{"aaaab"},5};
int next[10], count;
count=BFIndexC(S1,0,T1);
printf("the comparison counts of Brute-Force is:%d\n",count);
GetNext(T1, next);
count=KMPIndexC(S1,0,T1,next);
printf("the comparison counts of KMP is:%d\n",count);
上一篇:2014年山东高职专科排名总表
下一篇:海鲜厨房教学设计