📄 charmatch.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 + -