标签:style blog color io os ar sp div c
#include<iostream> using namespace std; int BFMatch(char* s,char* p) { int i=0; int j=0; while(i<strlen(s)) { while(s[i]==p[j]&&j<strlen(p)) { j++; i++; } if(j==strlen(p)) return i-strlen(p); i=i-j+1; } return -1; } int main() { char* s="123a"; char* p="a"; cout<<BFMatch(s,p)<<endl; getchar(); }
标签:style blog color io os ar sp div c
原文地址:http://www.cnblogs.com/Small-Life/p/4009761.html