📄 2207000_ac_512ms_372k.c
字号:
# include <stdio.h>
# include <string.h>
struct node
{
int len;
char word[16];
}dic[10001];
int check1(char a[],char b[])
{
int i;
char tmp[16];
strcpy(tmp,b);
for(i = 0; tmp[i]!='\0'; i++)
{
strcpy(&tmp[i],&tmp[i+1]);
if(strcmp(tmp,a)==0)
return 1;
strcpy(tmp,b);
}
return 0;
}
int check2(char a[],char b[])
{
int i;
for(i = 0; b[i]!='\0'; i++)
{
if(a[i]==b[i])
continue;
else
if(strcmp(&a[i+1],&b[i+1])==0)
return 1;
else
return 0;
}
return 0;
}
void input()
{
int i = 0, l, no, n, mark;
char tmp[16], output[10001][16];
while(scanf("%s",tmp)==1&&strcmp(tmp,"#")!=0)
{
strcpy(dic[i].word,tmp);
dic[i++].len = strlen(tmp);
}
n = i;
while(scanf("%s",tmp)==1&&strcmp(tmp,"#")!=0)
{
mark = no = 0;
printf("%s",tmp);
l = strlen(tmp);
for(i = 0; i < n; i++)
{
if(dic[i].len==l)
{
if(strcmp(dic[i].word,tmp)==0)
{
printf(" is correct\n");
goto con;
}
if(check2(dic[i].word,tmp))
{
mark = 1;
strcpy(output[no++],dic[i].word);
}
}
if(dic[i].len-l==-1)
{
if(check1(dic[i].word,tmp))
{
mark = 1;
strcpy(output[no++],dic[i].word);
}
}
if(dic[i].len==l+1)
{
if(check1(tmp,dic[i].word))
{
mark = 1;
strcpy(output[no++],dic[i].word);
}
}
}
printf(":");
if(mark)
{
for(i = 0; i < no; i++)
printf(" %s",output[i]);
}
printf("\n");
con: ;
}
}
int main()
{
input();
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -