问一个串是否是另一个的子串(不必连续也行),比较水,直接一个一个枚举出来即可

 起初定义串长度太小,总到时SGV错误

#include <stdio.h>
#include
<string.h>
int main()
{
char a[99999],b[99999];
while(scanf("%s%s",a,b)!=EOF)
{
int len1=strlen(a),len2=strlen(b),i,j;
if(len2<len1)printf("No\n");
else
{
for(i=0,j=0;i<len1&&j<len2;j++)
if(a[i]==b[j])i++;
if(i==len1)printf("Yes\n");
else printf("No\n");
}
}
return 0;
}

相关文章:

  • 2021-12-13
  • 2021-07-28
  • 2021-08-23
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2021-06-25
  • 2021-10-17
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案