Time Limit: 1000MS Memory limit: 65536K
题目描述
给定两个字符串string1和string2,判断string2是否为string1的子串。
输入
输入包含多组数据,每组测试数据包含两行,第一行代表string1,第二行代表string2,string1和string2中保证不出现空格。
输出
对于每组输入数据,若string2是string1的子串,则输出"YES",否则输出"NO"。
示例输入
abc a 123456 45 abc ddd
示例输出
YES YES NO#include<iostream> #include<string.h> #define N 999 using namespace std; int main() { char str1[N],str2[N]; while(cin>>str1>>str2) { if(strstr(str1,str2)) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }