简单C++问题 在线等.待答.案 .

img

                                                   总提交:76 刘试通过:42
描述
 现在给定字符串a,请判断字符串a是否包含字符串b
输入
 输入有两行,第一行为字符串a,长度不超过20字符
  第二行为字符串b,长度为1。
输出
 若包含请输出"exist”,不存在请输出“notexist”.
样例输入
 RW
 R
样例输出
 exist

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    string s1,s2;
    cin >> s1;
    cin >> s2;
    if((n = s1.find(s2,0)) == string::npos){
        cout << "notexist";
    }else{
        cout << "exist";
    }
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
void main(){
 string str1, str2;
    cin >> str1;
    cin >> str2;
    if(strstr(str1.c_str(),str2.c_str())!=nullptr)
        cout << "exist";
    else
        cout << "notexist";
}