poj1035
来源:互联网 发布:脱口秀大会 知乎 编辑:程序博客网 时间:2024/05/21 11:27
#include<iostream>
#include<string>
using namespace std;
string dic[10000];
int diclength = 0;
string word;
string che[50];
int chelength = 0;
string matched[50] = {""};
void check();
int main()
{
while(cin>>word&&word!="#")
dic[diclength++] = word;
while (cin >> word&&word != "#")
che[chelength++] = word;
check();
for(int i=0;i<chelength;i++)
{
if (matched[i] == "#")
cout << che[i] << " is correct" << endl;
else
cout << che[i] << ":" << matched[i]<<endl;
}
return 0;
}
void check()
{
for(int i=0;i<chelength;i++)
{
word = che[i];
for(int j=0;j<diclength;j++)
{
int cha = 0;
cha = word.length() - dic[j].length();
int error = 0;
if(cha==0)
{
for(int t=0;t<word.length();t++)
{
if(word[t]!=dic[j][t])
{
error++;
if (error > 1)
break;
}
}
if (error == 1)
{
matched[i] += " ";
matched[i] += dic[j];
}
else if(error==0)
{
matched[i] = "#";
break;
}
}
if(cha==1)
{
for(int t=0,p=0;t<word.length();t++,p++)
{
if(word[t]!=dic[j][p])
{
error++;
if (error > 1)
break;
p--;
}
}
if (error == 1)
{
matched[i] += " ";
matched[i] += dic[j];
}
}
if (cha == -1)
{
for (int t = 0, p = 0; t<dic[j].length(); t++, p++)
{
if (word[p] != dic[j][t])
{
error++;
if (error > 1)
break;
p--;
}
}
if (error == 1)
{
matched[i] += " ";
matched[i] += dic[j];
}
}
}
}
}
#include<string>
using namespace std;
string dic[10000];
int diclength = 0;
string word;
string che[50];
int chelength = 0;
string matched[50] = {""};
void check();
int main()
{
while(cin>>word&&word!="#")
dic[diclength++] = word;
while (cin >> word&&word != "#")
che[chelength++] = word;
check();
for(int i=0;i<chelength;i++)
{
if (matched[i] == "#")
cout << che[i] << " is correct" << endl;
else
cout << che[i] << ":" << matched[i]<<endl;
}
return 0;
}
void check()
{
for(int i=0;i<chelength;i++)
{
word = che[i];
for(int j=0;j<diclength;j++)
{
int cha = 0;
cha = word.length() - dic[j].length();
int error = 0;
if(cha==0)
{
for(int t=0;t<word.length();t++)
{
if(word[t]!=dic[j][t])
{
error++;
if (error > 1)
break;
}
}
if (error == 1)
{
matched[i] += " ";
matched[i] += dic[j];
}
else if(error==0)
{
matched[i] = "#";
break;
}
}
if(cha==1)
{
for(int t=0,p=0;t<word.length();t++,p++)
{
if(word[t]!=dic[j][p])
{
error++;
if (error > 1)
break;
p--;
}
}
if (error == 1)
{
matched[i] += " ";
matched[i] += dic[j];
}
}
if (cha == -1)
{
for (int t = 0, p = 0; t<dic[j].length(); t++, p++)
{
if (word[p] != dic[j][t])
{
error++;
if (error > 1)
break;
p--;
}
}
if (error == 1)
{
matched[i] += " ";
matched[i] += dic[j];
}
}
}
}
}
阅读全文
0 0
- poj1035
- poj1035
- poj1035
- poj1035
- poj1035
- poj1035
- poj1035
- POJ1035
- poj1035
- poj1035
- poj1035
- POJ1035
- poj1035
- 查找 poj1035
- poj1035 模拟
- POJ1035(字符串)
- POJ1035解题报告
- poj1035 Spell checker
- android动态权限工具类
- python:浅析python 中__name__ = '__main__' 的作用
- 《Web渗透技术及实战案例解析》pdf
- wifi display
- LeetCode 438. Find All Anagrams in a String
- poj1035
- 描述统计学基础
- xsy1025 link-cut-tree+线段树
- SpringMVC学习笔记(四):地址映射RequestMapping
- css实战(第一天)
- maven pom.xml jstl
- 《程序员代码面试指南 IT名企算法与数据结构题目最优解》左程云著 pdf
- 修改notepad++的主题(背景色、前景色、字体等)
- c++第五次实验-分数类