数据结构实验三实验报告(5)
时间:2025-07-11
时间:2025-07-11
数据结构实验报告
count=BFIndexC(S2,0,T2);
printf("the comparison counts of Brute-Force is:%d\n",count);
GetNext(T2, next);
count=KMPIndexC(S1,0,T2,next);
printf("the comparison counts of KMP is:%d\n",count);
}
4-20
/*SString.h*/
typedef struct
{
char str[MaxSize];
int length;
}String;
void Initiate(String *S)
{
S->length=0;
}
int Insert(String *S, int pos, String T)
{
int i;
if(pos<0||pos>S->length)
{
printf("The parameter pos is error!\n");
return 0;
}
else if(S->length+T.length>MaxSize)
{
printf("The space of the array is not enough!\n");
return 0;
}
else
{
for(i=S->length-1; i>=pos; i--)
S->str[i+T.length]=S->str[i];
for(i=0; i<T.length; i++)
S->str[pos+i]=T.str[i];
S->length=S->length+T.length;
return 1;
}
}
上一篇:2014年山东高职专科排名总表
下一篇:海鲜厨房教学设计