// KMP 算法
#include<cstdio>
#include <windows.h>
int n, m, pos, pi[102];
char p[102], t[150002];
char file[30] = "..\\output\\output_ .txt";
int Compute_Prefix_Function( );
int KMP_Match( );
int main( )
{
freopen( "..\\input\\input.txt", "r", stdin );
LARGE_INTEGER nFreq;
LARGE_INTEGER nBeginTime;
LARGE_INTEGER nEndTime;
double time1, time2;
for( int num = 1; num <= 5; num++ )
{
scanf( "%d%d", &n, &m );
scanf( "%s%s", t+1, p+1 );
file[17] = 48 + num;
freopen( file, "a", stdout );
QueryPerformanceFrequency( &nFreq );
QueryPerformanceCounter( &nBeginTime );
Compute_Prefix_Function( );
QueryPerformanceCounter(&nEndTime);
time1=(double)(nEndTime.QuadPart-nBeginTime.QuadPart)/(double)nFreq.QuadPart * 1000000;
QueryPerformanceCounter( &nBeginTime );
pos = KMP_Match( );
QueryPerformanceCo
代码染色!
最新推荐文章于 2021-02-26 18:18:33 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)