poj 1035 纯正的字符串水
| Time Limit: 2000MS | Memory Limit: 65536K | |
| Total Submissions: 22673 | Accepted: 8258 |
Description
?deleting of one letter from the word; ?replacing of one letter in the word with an arbitrary letter; ?inserting of one arbitrary letter into the word. Your task is to write the program that will find all possible replacements from the dictionary for every given word.
Input
Output
Sample Input
i
is
has
have
be
my
more
contest
me
too
if
award
#
me
aware
m
contest
hav
oo
or
i
fi
mre
#
Sample Output
me is correct
aware: award
m: i my me
contest is correct
hav: has have
oo: too
or:
i is correct
fi: i
mre: more me
#include<stdio.h>
#include<string.h>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int main(){
vector<string>q;
while(cin>>s){
if(s=="#")
break;
q.push_back(s); }
while(cin>>s){
if(s=="#")
break;
int len=s.size();
bool flag=false;
cout<<s;
for(int i=;i<q.size();i++){
if(s==q[i]){
flag=true;
cout<<" is correct"<<endl;
break;
}
} if(!flag){
cout<<":";
for(int i=;i<q.size();i++){
int len1=q[i].size();
int temp=len1-len;
if(temp>||temp<-)
continue;
int d=;
if(temp==){
for(int j=;j<len;j++){
if(s[j]!=q[i][j])
d++;
}
if(d==)
cout<<' '<<q[i];
} else if(temp==-){
for(int j=;j<len;j++){
if(s[j]==q[i][d]){
d++;
}
}
if(d==len1)
cout<<' '<<q[i];
} else if(temp==){
for(int j=;j<len1;j++){
if(s[d]==q[i][j]){
d++;
}
}
if(d==len)
cout<<' '<<q[i];
} }
cout<<endl;
} }
return ;
}
poj 1035 纯正的字符串水的更多相关文章
- POJ 1035 Spell checker 字符串 难度:0
题目 http://poj.org/problem?id=1035 题意 字典匹配,单词表共有1e4个单词,单词长度小于15,需要对最多50个单词进行匹配.在匹配时,如果直接匹配可以找到待匹配串,则直 ...
- poj 1035 Spell checker ( 字符串处理 )
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16675 Accepted: 6087 De ...
- POJ 1035 代码+具体的目光
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19319 Accepted: 7060 Descri ...
- poj 3080 Blue Jeans(水题 暴搜)
题目:http://poj.org/problem?id=3080 水题,暴搜 #include <iostream> #include<cstdio> #include< ...
- 1222: FJ的字符串 [水题]
1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1 = “A” A2 = ...
- 1001 字符串“水”题(二进制,map,哈希)
1001: 字符串“水”题 时间限制: 1 Sec 内存限制: 128 MB提交: 210 解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- poj 1035 Spell checker(水题)
题目:http://poj.org/problem?id=1035 还是暴搜 #include <iostream> #include<cstdio> #include< ...
- POJ 3080 (字符串水题) Blue Jeans
题意: 找出这些串中最长的公共子串(长度≥3),如果长度相同输出字典序最小的那个. 分析: 用库函数strstr直接查找就好了,用KMP反而是杀鸡用牛刀. #include <cstdio> ...
随机推荐
- 矩阵——特征向量(Eigenvector)
原文链接 矩阵的基础内容以前已经提到,今天我们来看看矩阵的重要特性——特征向量. 矩阵是个非常抽象的数学概念,很多人到了这里往往望而生畏.比如矩阵的乘法为什么有这样奇怪的定义?实际上是由工程实际需要定 ...
- 九九乘法表(Python实现)
a = 1 #while实现 while a: b = 1 while b: print(str(b)+'*'+str(a),end='=') print(a*b,end=' ') if b == a ...
- 前端css之文本操作及块级元素和行内元素
1.文本操作 1.1文本颜色(color) 颜色指定方式: 十六进制值 - 如: #FF0000 一个RGB值 - 如: RGB(255,0,0) 颜色的名称 - 如: red 1.2水平对齐方式 ...
- RestKit ,一个用于更好支持RESTful风格服务器接口的iOS库
简介 RestKit 是一个用于更好支持RESTful风格服务器接口的iOS库,可直接将联网获取的json/xml数据转换为iOS对象. 项目主页: RestKit 最新示例: 点击下载 注意: 如果 ...
- 记一次FTP下载踩坑的故(shi)事(gu)
下班前领导忽然要求我将客户的日志服务器上一些日志拷贝到测试服务器中,不过领导只提供给我FTP的连接方式,很明显就是要我用FTP方式去做啦 一般来说FTP批量下载也就上网随便找个脚本的事,但是却成了我疯 ...
- ### Cause: java.lang.reflect.UndeclaredThrowableException
### Cause: java.lang.reflect.UndeclaredThrowableException Caused by: org.apache.ibatis.exceptions.Pe ...
- POJ:3421-X-factor Chains(因式分解)(全排列)
X-factor Chains Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7986 Accepted: 2546 Descr ...
- hasattr() & getattr() & setattr()
Python的hasattr() getattr() setattr() 函数使用方法详解 感谢作者 ---> 原文链接 hasattr(object, name) 判断一个对象里面是否有n ...
- 资料--JavaScript原型链
JavaScript原型链 原文出处:https://www.cnblogs.com/chengzp/p/prototype.html 目录 创建对象有几种方法 原型.构造函数.实例.原型链 inst ...
- eclipse、myeclipse 反编译插件 轻松查看源代码
java反编译插件:Eclipse Class Decompiler,能够很方便的使用本插件查看类库源码,以及采用本插件进行Debug调试. eclipse中安装Eclipse Class Decom ...