简单,粗暴,可能还有Bug

-
#include <stdio.h>
-
#include <string.h>
-
-
int contain(char* source,char* target,int index){
-
int i=0;
-
for(;i<strlen(target);i++){
-
if(source[index]!=target[i]){
-
return -1;
-
}
-
else{
-
index=index+1;
-
}
-
}
-
return 1;
-
}
-
-
int main(){
-
char* source="Hello World!!Hello World!!!";
-
char* target="orl";
-
int i=0;
-
for(;i<strlen(source);i++){
-
if(contain(source,target,i)==1){
-
printf("%i\n",i);
-
}
-
}
-
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29254281/viewspace-1783405/
,如需转载,请注明出处,否则将追究法律责任。