PKU 1035 Spell checker(Vector+String应用)
题目大意:原题链接
1输入一个字符串,如果字典中存在该字符串,直接输出,否则;
2.删除,替换,或插入一个字母。如果使得输入字符串==字典中已经有的单词,输出该单词,否则。
3.直接输入下一个字符串,继续匹配.
- #include<vector>
- #include<string>
- #include<iostream>
- using namespace std;
- string s;
- int main(){
- vector<string> dict;
- while(cin>>s){
- if(s=="#") break;
- dict.push_back(s);
- }
- while(cin>>s){
- if(s=="#") break;
- cout<<s;
- int len1=s.size();
- bool sign=false;
- for(int i=;i<dict.size();i++){
- if(s==dict[i]){
- cout<<" is correct"<<endl;
- sign=true;break;
- }
- }
- if(!sign){
- cout<<":";
- //枚举字典中每一个单词进行查找
- for(int i=;i<dict.size();i++){
- int len2=dict[i].size();
- int d=,delta=len2-len1;
- if(delta>||delta<-) continue;
- if(delta==-){//删除
- for(int j=;j<len1;j++){
- if(s[j]==dict[i][d])
- d++;
- }
- if(d==len2) cout<<' '<<dict[i];
- }
- else if(delta==){//替换
- for(int j=;j<len1;j++){
- if(s[j]!=dict[i][j])
- d++;
- }
- if(d==) cout<<' '<<dict[i];
- }
- else if(delta==){//插入
- for(int j=;j<len2;j++){
- if(s[d]==dict[i][j])
- d++;
- }
- if(d==len1) cout<<' '<<dict[i];
- }
- }
- cout<<endl;
- }
- }
- }
PKU 1035 Spell checker(Vector+String应用)的更多相关文章
- poj 1035 Spell checker
Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u J ...
- poj 1035 Spell checker ( 字符串处理 )
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16675 Accepted: 6087 De ...
- [ACM] POJ 1035 Spell checker (单词查找,删除替换添加不论什么一个字母)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18693 Accepted: 6844 De ...
- POJ 1035 Spell checker 字符串 难度:0
题目 http://poj.org/problem?id=1035 题意 字典匹配,单词表共有1e4个单词,单词长度小于15,需要对最多50个单词进行匹配.在匹配时,如果直接匹配可以找到待匹配串,则直 ...
- POJ 1035 Spell checker(串)
题目网址:http://poj.org/problem?id=1035 思路: 看到题目第一反应是用LCS ——最长公共子序列 来求解.因为给的字典比较多,最多有1w个,而LCS的算法时间复杂度是O( ...
- poj 1035 Spell checker(水题)
题目:http://poj.org/problem?id=1035 还是暴搜 #include <iostream> #include<cstdio> #include< ...
- 【POJ】1035 Spell checker
字典树. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib ...
- POJ 1035 Spell checker (模拟)
题目链接 Description You, as a member of a development team for a new spell checking program, are to wri ...
- POJ 1035 Spell checker 简单字符串匹配
在输入的单词中删除或替换或插入一个字符,看是否在字典中.直接暴力,172ms.. #include <stdio.h> #include <string.h> ]; ][], ...
随机推荐
- List去重复(List中存的是对象)
class ProductComparare : IEqualityComparer<YEWULIANG> { private Func<YEWULIANG, object> ...
- Ubuntu16.04 Tomcat9的安装
1. 从http://tomcat.apache.org/download-90.cgi 下载apache-tomcat-9.0.0.M11.tar.gz 2. 上传到Linux后移动到/opt/to ...
- hdu 1233:还是畅通工程(数据结构,图,最小生成树,普里姆(Prim)算法)
还是畅通工程 Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submis ...
- angularJs 多文件动态上传(删除其中一个文件的时候,要么file没被删除,要么删除了之后,点击事件失效)
<div cacModule.controller('CacScriptEditCtrl', CacScriptEditCtrl); CacScriptEditCtrl.$inject = [' ...
- hdu4734(记忆化搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 思路:记忆化搜索. #include<iostream> #include<c ...
- 一稿设计多端适配优雅的解决方案 - rem
规范目的 为提高前端团队开发效率,输出高质量的前端页面代码,提高UI设计还原度,特编写该规范文档.本文档如有不对或者不合适的地方请及时提出. JS代码块 (function (doc, win) { ...
- 分页技巧__在项目中使用QueryHelper辅助对象实现分页效果
分页技巧__在项目中使用QueryHelper辅助对象实现分页效果 QueryHelper 用于辅助拼接HQL语句 addCondition("t.type=?", "精 ...
- pushViewController自定义动画http://blog.csdn.net/ralbatr/article/details/22039233
本文转载至 http://blog.csdn.net/ralbatr/article/details/22039233 实现的主要代码如下: CATransition *transition = ...
- 在Hyper-V Linux VM如何选择LIS Linux集成服务
导读 很多工程师都知道,如果你选择在 Hyper-V 中运行 Linux guest VM,要获得最好的使用体验,必需针对你所使用的 Linux 发行版和使用场景选择 Linux Integratio ...
- 如何把IOS应用,发给别人测试?
ios应用,除了用XCODE连接真实设备调试以外,也可以制作ipa安包,发给别人测试.下面是具体步骤: 1. 把要测试的设备标识添加到你苹果开发账号的调试设备里.(可以用xcode或者itools查看 ...