#include <stdio.h>
char *search(char *s,char *p);
int main(){
printf("NULL %s\n", search
("abcdefg","aaa")); printf("abcdefg %s\n", search
("abcdefg","a")); printf("g %s\n", search
("abcdefg","g")); printf("NULL %s\n", search
("abcdefg","ac")); printf("defg %s\n", search
("abcdefg","de")); printf("fg %s\n", search
("abcdefg","fg")); printf("NULL %s\n", search
("abcdefg","df")); printf("abcdefg %s\n", search
("abcdefg","")); printf("未定義 %s\n", search
("abcdefg",NULL
));/* 未定義 */ printf("未定義 %s\n", search
(NULL
,"a"));/* 未定義 */
return 0;
}
char *search(char *s,char *p){
return s&&p?*p?*s?((*p==*s)&&(s+1==search(s+1,p+1)))?s:search(s+1,p):NULL:s:NULL;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpjaGFyICpzZWFyY2goY2hhciAqcyxjaGFyICpwKTsKCmludCBtYWluKCl7CiAgICBwcmludGYoIk5VTEwgJXNcbiIsICAgICBzZWFyY2goImFiY2RlZmciLCJhYWEiKSk7CiAgICBwcmludGYoImFiY2RlZmcgJXNcbiIsICBzZWFyY2goImFiY2RlZmciLCJhIikpOwogICAgcHJpbnRmKCJnICVzXG4iLCAgICAgICAgc2VhcmNoKCJhYmNkZWZnIiwiZyIpKTsKICAgIHByaW50ZigiTlVMTCAlc1xuIiwgICAgIHNlYXJjaCgiYWJjZGVmZyIsImFjIikpOwogICAgcHJpbnRmKCJkZWZnICVzXG4iLCAgICAgc2VhcmNoKCJhYmNkZWZnIiwiZGUiKSk7CiAgICBwcmludGYoImZnICVzXG4iLCAgICAgICBzZWFyY2goImFiY2RlZmciLCJmZyIpKTsKICAgIHByaW50ZigiTlVMTCAlc1xuIiwgICAgIHNlYXJjaCgiYWJjZGVmZyIsImRmIikpOwogICAgcHJpbnRmKCJhYmNkZWZnICVzXG4iLCAgc2VhcmNoKCJhYmNkZWZnIiwiIikpOwogICAgcHJpbnRmKCLmnKrlrprnvqkgJXNcbiIsICAgc2VhcmNoKCJhYmNkZWZnIixOVUxMKSk7Lyog5pyq5a6a576pICovCiAgICBwcmludGYoIuacquWumue+qSAlc1xuIiwgICBzZWFyY2goTlVMTCwiYSIpKTsvKiDmnKrlrprnvqkgKi8KICAgIAogICAgcmV0dXJuIDA7Cn0KCmNoYXIgKnNlYXJjaChjaGFyICpzLGNoYXIgKnApewogICAgcmV0dXJuIHMmJnA/KnA/KnM/KCgqcD09KnMpJiYocysxPT1zZWFyY2gocysxLHArMSkpKT9zOnNlYXJjaChzKzEscCk6TlVMTDpzOk5VTEw7Cn0K