poj 1035 Spell checker
来源:互联网 发布:人肉俄罗斯转盘 知乎 编辑:程序博客网 时间:2024/06/05 17:31
http://poj.org/problem?id=1035
暴力检索字符串,逐个处理即可。
#include<iostream>#include<cstring>using namespace std;char a[11111][22];char b[55][22]; int ai=1,bj=1;bool d1(char a[],char b[]){ int l1=strlen(a); int flag=0; for(int i=0;i<l1;i++) if(a[i]!=b[i]) { flag++; if(flag>1) return false; } return true;}bool d2(char a[],char b[]){ int l1=strlen(a); int i=0,j=0; int flag=0; while(i<l1) { if(a[i]!=b[j]) { i++; flag++; if(flag>1) return false; } else { i++; j++; } } return true;}int main(){ ai=1; bj=1; while(cin>>a[ai]&&a[ai][0]!='#') { ai++;}while(cin>>b[bj]&&b[bj][0]!='#'){bj++;}ai--;bj--;int i,j;for(i=1;i<=bj;i++){int flag=0; for(j=1;j<=ai;j++) { if(!strcmp(b[i],a[j])) { cout<<b[i]<<" is correct"<<endl; flag=1;}}if(flag==1)continue;cout<<b[i]<<": ";for(j=1;j<=ai;j++) { int l1=strlen(b[i]); int l2=strlen(a[j]); if(l1==l2) { if(d1(b[i],a[j])) cout<<a[j]<<" "; } else if(l1-l2==1) { if(d2(b[i],a[j])) cout<<a[j]<<" "; } else if(l1-l2==-1) { if(d2(a[j],b[i])) cout<<a[j]<<" "; } } cout<<endl;}return 0;}
阅读全文
0 0
- poj-1035-Spell checker
- poj 1035 Spell checker
- Poj 1035 --Spell checker
- Spell checker--POJ 1035
- poj 1035 Spell checker
- poj 1035 Spell checker
- POJ-1035-Spell checker
- poj 1035 Spell Checker
- POJ 1035 Spell checker
- poj 1035 Spell checker
- poj 1035 Spell checker
- poj 1035 Spell checker
- POJ 1035 Spell checker
- POJ 1035 Spell checker
- poj 1035 Spell checker
- POJ 1035 Spell checker
- poj 1035 Spell checker
- POJ 1035 Spell checker
- Effective Java
- C++ MD5
- 文章标题
- 数据结构 顺序查找和二分查找
- 软件工程(C编码实践篇)学习总结
- poj 1035 Spell checker
- UVA
- SD卡文件读写
- mysql字段text类型的使用
- 有关C++ 实现时extern 和const的问题
- poj 2231 Moo Volume
- 小程序合集1(素数、闰年、乘法表)
- centos 怎么用 基本知识
- pandas中利用get_dummies()进行独热编码(One-Hot encoding)