2-2 查找匹配字符串
#include
#include
using namespace std;
void main()
{
string a;
string b;
cout << "请输入一个关键字:" << endl; cin >> a;
cout << "请输入一个句子:" << endl; cin >> b;
string::size_type pos;
pos = b.find(a,0);
if (pos == string::npos)
{
cout << "MO MATCH!" << endl;
}
else
{
cout << "MATCH" << endl;
cout << hex << pos / 2 + 1 << endl; }
}