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> ...
随机推荐
- 合格PHP工程师的知识结构 (转载)
工作有些年头了,从学校开始自学ASP,偶然因为PHP一个功能爱上它(ASP上传代码要写好多,PHP基本几行就搞定了),从此走上了 ”拍黄片“ 之路.结合这几年的工作经验,说说我对PHP工程师知识结构的 ...
- ckplayer插件播放视频
官网:超酷网页视频 本篇介绍:插件播放视频, 添加插件(额外的功能), 视频格式之间的转换 PC端一般都是利用插件(Flash)来播放视频,可以支持很多格式.网上很多说这个插件的,这里只是做个记录 ...
- caffe在 14.04安装
同事安装遇到的问题,记录一下 需要把cuda里面带的opengl不安装才行,否则冲突.在安装时,首先和之前一样,切换到无图形界面,关掉lightdm,安装cuda时选择--no-opengl-lib, ...
- img适配问题解决方法
将img放到background中,将background-size设置为100%:只需要适配背景为img的元素的宽和高即可.
- Mac中Mysql开启远程访问(不同于linux直接改配置文件)
在mac中安装Mysql Workbench 用root用户连上安装的Mysql. 开启远程访问的服务 如下图可以看到是root用户绑定的是localhost 如果不做修改的话,直接访问是访问不了 ...
- 路由器基础配置之单臂路由实现vlan间通信
我们将以上面的拓扑图开始进行配置,目的为设置单臂路由实现vlan间通信,设置4个vlan,pc0,1,2为vlan10 pc3,4,5为vlan20:pc6,7,8为vlan30:server0,1为 ...
- python爬虫:利用正则表达式爬取豆瓣读书首页的book
1.问题描述: 爬取豆瓣读书首页的图书的名称.链接.作者.出版日期,并将爬取的数据存储到Excel表格Douban_I.xlsx中 2.思路分析: 发送请求--获取数据--解析数据--存储数据 1.目 ...
- python flask豆瓣微信小程序案例
项目步骤 定义首页模板index.html <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- tomcat7 配置 https安全访问
在apache-tomcat-7.0.33-windows-x64.zip配置https,结果在配置SSL时遇到一些问题 1.用JDK自带的keytool来生成私有密钥和自签发的证书,如下: keyt ...
- 关于Android SDK无法更新的解决办法
最新摆弄PhoneGap打包,所以需要安卓的环境,配置后,sdk更新实在是在慢了,上网找了一下,可能被强了,所有总结如下办法,最后弄好了,跟大家分享一下 具体步骤:1:打开SDK Manager.ex ...