字符串a中找字串b
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a, b;
cin >> a >> b;
cout << a.find(b) + 1 << endl;
system("pause");
return 0;
}
本文介绍了一种使用C++标准库函数find进行字符串查找的方法。通过一个简单的示例,演示了如何从一个字符串中查找子字符串的位置,并输出其起始位置。这对于理解和应用字符串操作非常有帮助。
字符串a中找字串b
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a, b;
cin >> a >> b;
cout << a.find(b) + 1 << endl;
system("pause");
return 0;
}
4637
1万+
900

被折叠的 条评论
为什么被折叠?