#include<iostream>
#include<fstream>
#include<string>
using namespace std;
string dict[10000];
string word;
int n=0;
void solve()
{
for(int i=0;i<n;i++)
{
if(dict[i]==word)
{
cout<<word<<" is correct"<<endl;
return ;
}
}
cout<<word<<":";
for(int i=0;i<n;i++)
{
int len1=dict[i].length();
int len2=word.length();
if(len1==len2-1)
{
int j=0;
int k=0;
bool flag=false;
for(;k<len2;k++)
{
if(dict[i][j]==word[k])
{
j++;
continue;
}
if(dict[i][j]!=word[k])
{
if(flag==false)
flag=true;
else
break;
}
}
if(j==len1&&k==len2)
cout<<" "<<dict[i];
}
else if(len1==len2+1)
{
int j=0;
int k=0;
bool flag=false;
for(;j<len1;j++)
{
if(dict[i][j]==word[k])
{
k++;
continue;
}
if(dict[i][j]!=word[k])
{
if(flag==false)
flag=true;
else
break;
}
}
if(j==len1&&k==len2)
cout<<" "<<dict[i];
}
else if(len1==len2)
{
bool flag=false;
int k;
for( k=0;k<len1;k++)
{
if(dict[i][k]!=word[k])
{
if(flag==false)
flag=true;
else
break;
}
}
if(k==len1)
cout<<" "<<dict[i];
}
}
cout<<endl;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
char input[40];
while(scanf("%s",input)!=EOF)
{
dict[n]=input;
if(dict[n]!="#")
{
n++;
}
else
{
while(scanf("%s",input)!=EOF)
{
word=input;
if(word=="#")
break;
solve();
}
break;
}
}
}
poj1035
最新推荐文章于 2012-06-08 22:21:05 发布