社区讨论
求救
B2118验证子串参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lyp5hsiq
- 此快照首次捕获于
- 2024/07/17 09:15 2 年前
- 此快照最后确认于
- 2024/07/17 10:19 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a,b;
cin>>a>>b;
int c=a.size(),d=b.size();
for(int i=1;i<=max(c,d);i++)
{
int e=0;
for(int j=i;j<=min(c,d)+i;j++)
{
if(a[j]==b[j])
{
e++;
}
}
if(e==min(c,d))
{
if(c>d)
{
cout<<b<<" is substring of "<<a<<endl;
}
else
{
cout<<a<<" is substring of "<<b<<endl;
}
return 0;
}
}
cout<<"No substring";
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...