Poj 1035 Spell checker
来源:互联网 发布:linux 查看网卡状态 编辑:程序博客网 时间:2024/06/06 14:11
2Y
1TLE于用最长公共子序列处理相似问题
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define N 10010char map[N][17];char ask[60];bool similar(char *map,char *ask){int i,j;int len_map=strlen(map),len_ask=strlen(ask);if(abs(len_map-len_ask)>1)return 0;int same;if(len_map>len_ask){same=0;i=0;for(j=0;j<len_map;j++)if(map[j]==ask[i]){i++;same++;}if(same==len_ask)return 1;return 0;}if(len_map<len_ask){same=0;i=0;for(j=0;j<len_ask;j++)if(ask[j]==map[i]){i++;same++;}if(same==len_map)return 1;return 0;}same=0;for(i=0;i<len_ask;i++)if(ask[i]!=map[i])same++;if(same>1)return 0;return 1;}int main(){int Nmap=0;while(scanf("%s",map[++Nmap])!=EOF){if(map[Nmap][0]=='#'){Nmap--;break;}}while(scanf("%s",ask)!=EOF){if(ask[0]=='#')break;int i,flag=0;for(i=1;i<=Nmap;i++)if(strcmp(map[i],ask)==0)flag=1;if(flag){printf("%s is correct\n",ask);continue;}printf("%s:");for(i=1;i<=Nmap;i++)if(similar(map[i],ask))printf(" %s",map[i]);printf("\n");}return 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
- 行为级和RTL级的区别
- 杭电2072 单词数(Trie tree或者STL)
- SHELL相关的特殊字符总结
- STM32 串口中断 BUG
- DBN(PoE and Contrastive Divergence)
- Poj 1035 Spell checker
- 一小时给未来
- C++中智能指针的工作原理和简单实现
- 0514-排序
- Android ListView常用用法
- Beaglebone black日记
- java中保存图片的缩略图
- Hadoop
- spring的依赖注入