
现在给定字符串a,请判断字符串a是否包含字符串b
输入
输入有两行,第一行为字符串a,长度不超过20字符
第二行为字符串b,长度不超过20字符。
输出
若包含请输出"exist”,不存在请输出"notexist
样例输入
RW
RW
样例输出
exist
#include<iostream>
#include<cstring>
using namespace std;
char a[20], b[20];
int main() {
cin.getline(a, 20);
cin.getline(b, 20);
if(strstr(a, b))
cout << "exist";
else
cout << "not exist";
return 0;
}
#include<stdlib.h>
#include<string.h>
using namespace std;
int main()
{
char str[20];
char substr[20];
gets(str);
gets(substr);
if(strstr(str,substr))
cout<<"exist";
else
cout<<"not exist";
return 0;
}