看到npos我笑了
查看原帖
看到npos我笑了
1247040
V_HAPPY666楼主2024/4/5 08:20

本题不需要那么复杂,直接将find的返回值转int,判断是否为-1即可

核心代码如下

	if((int)s1.find(s2)!=-1)
	{
		cout<<s2<<" is substring of "<<s1;
	}
	else if((int)s2.find(s1)!=-1)
	{
		cout<<s1<<" is substring of "<<s2;
	}

2024/4/5 08:20
加载中...