poj1305

#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std; 

map<string,int>mp;

#define maxn 10000 +10
string s[maxn];


int main()
{
	int top=0;
	for(;cin>>s[top];)
	{
		if(s[top]=="#")break;
		mp[s[top]]=top+1;
		top++;
	}



	string sk;
	for(;cin>>sk&&sk!="#";)
	{
		if(mp[sk]){cout<<sk+" is correct"<<endl;continue;}
		else
		{
			cout<<sk<<":";
			for(int j=0;j<top;j++)
				if(abs((int)(s[j].size()-sk.size()))<=1)
				{
					if(s[j].size()-1==sk.size())
					{
						string sf=sk;
						int ok=0;int l;
						for(l=0;l<sk.size();l++)
						{
							if(s[j][l]!=sf[l])
							{
								sf.insert(l,1,s[j][l]);   ok=1;
								break;   
							}
						}   
						if(!ok)sf.insert(l,1,s[j][l]);
						if(sf==s[j])cout<<" "+s[j];         
					}
					else if(s[j].size()==sk.size()-1)
					{
						string sf=s[j];int ok=0;int l;
						for(l=0;l<sf.size();l++)
						{
							if(sk[l]!=sf[l])
							{
								sf.insert(l,1,sk[l]);   ok=1;
								break;   
							}
						}     

						if(!ok) sf.insert(l,1,sk[l]);
						if(sf==sk)cout<<" "+s[j];
					}

					else if(s[j].size()==sk.size())
					{
						string sf=sk;
						for(int l=0;l<sf.size();l++)
						{
							if(sf[l]!=s[j][l])
							{
								sf.replace(l,1,1,s[j][l]);  
								break;
							}  

						}   
						if(sf==s[j])cout<<" "+s[j];

					}

				}

		}
		cout<<endl;
	}     

	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值