POJ 1035 Spell checker(字符串)
2012-12-13 11:31
691 查看
题目链接
考虑各种情况,然后注意敲的稳一点,忘考虑一种情况,2Y.
考虑各种情况,然后注意敲的稳一点,忘考虑一种情况,2Y.
#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <string> #include <map> using namespace std; char word[10001][21]; char s[21]; int len[10001]; int Abs(int x) { if(x < 0) return -x; else return x; } int main() { int i,j,n,k1,k,L,z; map<string,int>mp; for(i = 1;;i ++) { scanf("%s",word[i]); len[i] = strlen(word[i]); if(word[i][0] == '#') break; mp[word[i]] = 1; } n = i-1; for(i = 1;;i ++) { scanf("%s",s); if(s[0] == '#') break; L = strlen(s); if(mp[s]) { printf("%s is correct\n",s); continue; } printf("%s:",s); for(j = 1;j <= n;j ++) { if((len[j]-L) > 1) continue; if(len[j] == L) { z = 0; for(k = 0;k < L;k ++) { if(s[k] != word[j][k]) z ++; if(z >= 2) break; } if(z == 1) printf(" %s",word[j]); } else if(len[j] > L) { z = 0; for(k = 0,k1 = 0;k < L;k ++,k1 ++) { if(s[k] != word[j][k1]) { if(s[k] == word[j][k1+1]) k1 ++; else break; z ++; } } if(k == L&&k1 == len[j]&&z == 1) printf(" %s",word[j]); else if(k == L&&k1 == len[j]-1&&z == 0) printf(" %s",word[j]); } else { z = 0; for(k = 0,k1 = 0;k < L;k ++,k1 ++) { if(s[k] != word[j][k1]) { if(s[k+1] == word[j][k1]) k ++; else break; z ++; } } if(k == L&&k1 == len[j]&&z == 1) printf(" %s",word[j]); else if(k == L+1&&k1 == len[j]+1&&z == 1)//随便试了一组,这里就查出错了。。aaa aaaa printf(" %s",word[j]); } } printf("\n"); } return 0; }
相关文章推荐
- POJ 1035 Spell checker 字符串容错检查
- poj 1035 Spell checker【字符串】
- Spell checker POJ 1035 字符串
- POJ1035——Spell checker(字符串处理)
- poj_1035 Spell checker(字符串处理)
- poj 1035 Spell Checker —— 字符串
- poj 1035 Spell checker ( 字符串处理 )
- POJ 1035 Spell checker 字符串 难度:0
- 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 (字符串模拟)