Problem G: 可忽略大小写的子串求解(选做)

Problem G: 可忽略大小写的子串求解(选做)

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 158  Solved: 104
[Submit][Status][Web Board][Creator:]

Description

编写函数bool instr(const char *s1const char *s2 int start = 0int compare=0),判断串s2是否在串s1中当中,是则返回true,否则返回false。

参数start是在s1当中的搜索起始位置,默认为0;compare为比较方式,0为二进制比较,1为文本比较(忽略英文大小写)。在main函数当中通过不同的例子验证该函数的效果。

cout << instr("abcd" "bcd" 0 0) << endl;  //1

cout << instr("abcd" "bcd" 0 1) << endl;  //1

cout << instr("abcd" "bcd" 2 1) << endl;  //0

cout << instr("aabcd" "BCD" 0 0) << endl;  //0

cout << instr("aabcd" "BCD" 0 1) << endl;  //1

cout << instr("aaabcd" "BCD" 1 1) << endl;  //1

Input

分行依次输入两个字符串和两个整数,依次对应四个参数。

Output

仅一个字符串,内容为YES或者NO。

Sample Input

aabcd
BCD
0
0

Sample Output

NO
[Submit][Status]