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

📄 charmatch.cpp

📁 基于正则表达式的字符串匹配
💻 CPP
字号:
// charmatch.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "stdlib.h"
#include <iostream>

using namespace std;

int match(char main[], char sub[])
{
int i(0),j(0);

while(main[i+j]!='\0'&&sub[j]!='\0')
{
if(main[i+j]==sub[j])j++;
else
{
i++;j=0;
}
}

if(sub[j]=='\0')
return i;

else 
return -1;


}

int _tmain(int argc, _TCHAR* argv[])
{
	char *p="abcdefghij";
	char *p1="cde";
	cout<<match(p,p1)<<endl;
	return 0;
}

⌨️ 快捷键说明

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