#include <stdio.h>
char* search(char *text, char *pattern)
{
int i, seq;
for(seq = 0; text[seq] != '\0'; seq++){
for(i = 0; pattern[i] != '\0'; i++){
if(pattern[i] != text[seq+i]){
seq += i;
break;
}
}
if(pattern[i] == '\0'){
return text+seq;
}
}
return NULL;
}
int main(int argc, char *argv[])
{
char *r = search("abbbc", "bbc");
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpjaGFyKiBzZWFyY2goY2hhciAqdGV4dCwgY2hhciAqcGF0dGVybikKewogICAgaW50IGksIHNlcTsKIAogICAgZm9yKHNlcSA9IDA7IHRleHRbc2VxXSAhPSAnXDAnOyBzZXErKyl7CiAgICAgICAgZm9yKGkgPSAwOyBwYXR0ZXJuW2ldICE9ICdcMCc7IGkrKyl7CiAgICAgICAgICAgIGlmKHBhdHRlcm5baV0gIT0gdGV4dFtzZXEraV0pewogICAgICAgICAgICAgICAgc2VxICs9IGk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZihwYXR0ZXJuW2ldID09ICdcMCcpewogICAgICAgICAgICByZXR1cm4gdGV4dCtzZXE7CiAgICAgICAgfQogICAgfQogCiAgICByZXR1cm4gTlVMTDsKfQogCmludCBtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pCnsKICAgIGNoYXIgKnIgPSBzZWFyY2goImFiYmJjIiwgImJiYyIpOwogICAgcHV0cyhyKTsKIAogICAgcmV0dXJuIDA7Cn0K