poj 1035
2013-04-18 22:07
197 查看
暴力水过,79ms
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char tx[10000+10][20];
char s[20];
int len[10000+10],loc[10000+10];
int main()
{
int i=0;
while(scanf("%s",tx[i]))
{
if(strcmp(tx[i],"#")==0) break;
len[i]=strlen(tx[i]);
i++;
}
int tot=0,k,p,flag;
while(scanf("%s",s))
{
tot=0;
if(strcmp(s,"#")==0) break;
int j,le=strlen(s);
for(j=0;j<i;j++)
{
flag=0;
if(le==len[j])
{
for(k=0;k<le&&flag<=1;k++)
{
if(s[k]!=tx[j][k]) flag++;
}
if(flag==0) break;
else if(flag==1) loc[tot++]=j;
}
else if(le==(len[j]+1))
{
flag=0;
for(k=0,p=0;k<len[j]&&flag<=1;)
{
if(s[p]!=tx[j][k])
{
flag++;
p++;
}
else
{
p++;
k++;
}
}
if(flag<=1) loc[tot++]=j;
}
else if((le+1)==len[j])
{
flag=0;
for(k=0,p=0;p<le&&flag<=1;)
{
if(s[p]!=tx[j][k])
{
flag++;
k++;
}
else
{
p++;
k++;
}
}
if(flag<=1) loc[tot++]=j;
}
}
if(j<i) printf("%s is correct\n",s);
else
{
printf("%s:",s);
for(k=0;k<tot;k++) printf(" %s",tx[loc[k]]);
printf("\n");
}
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char tx[10000+10][20];
char s[20];
int len[10000+10],loc[10000+10];
int main()
{
int i=0;
while(scanf("%s",tx[i]))
{
if(strcmp(tx[i],"#")==0) break;
len[i]=strlen(tx[i]);
i++;
}
int tot=0,k,p,flag;
while(scanf("%s",s))
{
tot=0;
if(strcmp(s,"#")==0) break;
int j,le=strlen(s);
for(j=0;j<i;j++)
{
flag=0;
if(le==len[j])
{
for(k=0;k<le&&flag<=1;k++)
{
if(s[k]!=tx[j][k]) flag++;
}
if(flag==0) break;
else if(flag==1) loc[tot++]=j;
}
else if(le==(len[j]+1))
{
flag=0;
for(k=0,p=0;k<len[j]&&flag<=1;)
{
if(s[p]!=tx[j][k])
{
flag++;
p++;
}
else
{
p++;
k++;
}
}
if(flag<=1) loc[tot++]=j;
}
else if((le+1)==len[j])
{
flag=0;
for(k=0,p=0;p<le&&flag<=1;)
{
if(s[p]!=tx[j][k])
{
flag++;
k++;
}
else
{
p++;
k++;
}
}
if(flag<=1) loc[tot++]=j;
}
}
if(j<i) printf("%s is correct\n",s);
else
{
printf("%s:",s);
for(k=0;k<tot;k++) printf(" %s",tx[loc[k]]);
printf("\n");
}
}
return 0;
}
相关文章推荐
- POJ 1035 Fermat vs. Pythagoras(毕达哥拉斯三元组)
- [POJ1035 Spell checker]
- 【POJ 1035】Spell checker
- POJ 1035 Spell checker
- POJ1035-Spell checker(java版)
- POJ 1035 Spell checker 字符串
- poj 1035 Spell Checker —— 字符串
- poj 1035 字符串处理
- poj 1035 Spell checker
- POJ1035
- poj 1035 Spell checker (锻炼自己的编码能力)
- POJ 1035 Spell checker
- POJ 1035:Spell checker:字符串操作
- poj 1035 Spell Checker
- poj1035 字典匹配
- POJ 1035 Spell checker
- POJ 1035 Spell checker
- poj 1035 Spell checker
- poj 1035 Spell checker【字符串】
- Spell checker(poj 1035)