⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringmatch.cpp

📁 字符串的模式匹配(KMP算法)
💻 CPP
字号:
// stringmatch.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Mstring.h"
#include <fstream>

int main(int argc, char* argv[])
{
	while(1){
	ifstream infile;
	string tstr,sstr;
	int line=1,pos=0;
	bool flag=false;
	cout<<"\nInput the string you want to find:";
	cin>>tstr;
	Mstring mstr(tstr);
	infile.open("stringmatch.cpp");
	while(getline(infile,sstr)){
		mstr.set_sstr(sstr);
		pos=mstr.index_KMP();
		if(pos){
			cout<<"Found in line "<<line<<",position "
				<<pos<<endl;
			flag=true;
		}
		line++;
	}
	if(!flag) cout<<"Not found!\n";
	infile.close();
	}
	return 0;
}
/*If you intend using humor in your talk to make people smile, you must 
knowhow to identify shared experiences and problems. Your humor must 
be relevant tothe audience and should help to show them that you are 
one of them or that you understand their situation and are in sympathy 
with their point of view. Depending on whom you are addressing, the 
problems will be different. If you are talking to a group of managers, 
you may refer to the disorganized methods of their secretaries; 
alternatively if you are addressing secretaries, you may want to 
comment on their disorganized bosses.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -