

思路:没有思路。没有理解题意。不知道只剪一次,废了很多时间结果只需要分别从前边从后边比较。
代码:
#include"cstdio"
#include"algorithm"
#include"set"
#include"cmath"
#include"cstring"
using namespace std;
int main()
{
char s[105];
char t[12]=“CODEFORCES”;
scanf("%s",s);
int n=strlen(s);
int i=0,j=0;
while(i<10&&s[i]==t[i])
{
i++;
}
while(j<10&&s[n-1-j]==t[9-j])
{
j++;
}
if(i+j>=10)
{
printf(“YES\n”);
}
else
{
printf(“NO\n”);
}
return 0;
}
附上错误代码
#include"cstdio"
#include"algorithm"
#include"set"
#include"cmath"
#include"cstring"
using namespace std;
int main()
{
char s[105];
while(scanf("%s",&s))
{
char t[12]=“CODEFORCES”;
int n=strlen(s);
int k=0;
while(n–)
{
int l=0;
int i=0;
if(s[i]==t[l])
{
l++;
k++;
i++;
}
else
{
i++;
}
}
if(k》=10)
{
printf(“YES\n”);
}
else
{
printf(“NO\n”);
}
}
return 0;
}
Cutting Banner
最新推荐文章于 2019-08-29 12:50:23 发布
本文探讨了在CodeForces平台上解决字符串匹配问题的有效方法,通过对比前后缀字符,实现快速判断是否匹配,避免了不必要的复杂操作,节省了大量时间和资源。

380

被折叠的 条评论
为什么被折叠?



