题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93
#include <iostream>
using namespace std;
int main() {
string str1;
string str2;
cin >> str1 >> str2;
if (str1.size() > str2.size())
{
string temp = str2;
str2 = str1;
str1 = temp;
}
int cnt = 0;
for (int i = 0;i < str1.size();i++)
{
if (str2.find(str1[i]) != string::npos)
{
cnt += 1;
}
}
if (cnt == str1.size())
{
cout << "true";
}
else
{
cout << "false";
}
}
// 64 位输出请用 printf("%lld")

查看10道真题和解析