查找一个字符串是否包含另一字符串

数据分类处理

http://www.nowcoder.com/questionTerminal/9a763ed59c7243bd8ab706b2da52b7fd

/*
使用find()函数,看能否找到位置,如果可以找到,就说明包含
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
cin>>str;
string::size_type pos;
pos=str.find("12");
if(pos!=string::npos)
cout<<pos<<endl;
}

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务