Example #1
0
int main()
{
	struct timeval start;
	struct timeval end;
	unsigned long time;
	string text = "abcdefghi";
	string pattern = "def";

	Solution s;
	int res = s.KMP(text, pattern);

	gettimeofday(&start,NULL);

	/*****************************************/

	

	/*****************************************/

	gettimeofday(&end,NULL);

	cout << "index: " << res << endl;

	time = 1000000 * (end.tv_sec-start.tv_sec)+ end.tv_usec-start.tv_usec;
	cout << "runtime: " << time << " ums" << endl;
	return 0;
}
Example #2
0
int main()
{
	string h = "ababcabcacbab", t = "abaabcac";
	//string h = "", t = "";
	Solution *s = new Solution();

	cout << s->KMP(h, t , 0) << endl;
	
	system("pause");
	return 0;
}