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

简单C++问题 在线等.待答.案 .
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 南七灵 2021-11-16 11:30关注
#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; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报