0
已解决
翟谦瑞
新手守护
新手守护
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a,b;
int c,d;
cin>>a>>b;
c=a.find(b,0);
d=b.find(a,0);
if(c==0&&d==0)cout<<"No included";
else
{
if(c==1)cout<<b<<"is included in"<<a;
if(d==1)cout<<a<<"is included in"<<b;
}
return 0;
}
C++的各位大佬,麻烦看一下,结果不输出。
谁会做?
我会选一个我最满意的答案,并采纳。
0
已采纳
赵逸凡
初级启示者
初级启示者
定义 s1,s2;
输入字符串s1,s2;
如果(s1.find(s2,0)!=-1)
输出<<s2<<" is included in "<<s1;
否则 如果(s2.find(s1,0)!=-1)
输出<<s1<<" is included in "<<s2;
否则 输出<<"No including";
你的错点在于:
if(c==0&&d==0)应改成
if(c!=-1&&d!=0)//AC
就怕c,d=-1,-2......
0
0