using namespace std;
int main(){
string s="assxvc";
cin>>s1;
if(s.find(s1)!=s.npos){//返回值不等于字符串的npos值则s包含s1
cout<<s.find(s1);//返回的是s1在s的开始位置
}
else cout<<"不存在";
return 0;
}
C++:string字符串查找是否包含另一字符串的find()方法
最新推荐文章于 2024-03-03 11:20:56 发布