题目大意:原题链接

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应用)的更多相关文章

  1. poj 1035 Spell checker

    Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u   J ...

  2. poj 1035 Spell checker ( 字符串处理 )

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16675   Accepted: 6087 De ...

  3. [ACM] POJ 1035 Spell checker (单词查找,删除替换添加不论什么一个字母)

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18693   Accepted: 6844 De ...

  4. POJ 1035 Spell checker 字符串 难度:0

    题目 http://poj.org/problem?id=1035 题意 字典匹配,单词表共有1e4个单词,单词长度小于15,需要对最多50个单词进行匹配.在匹配时,如果直接匹配可以找到待匹配串,则直 ...

  5. POJ 1035 Spell checker(串)

    题目网址:http://poj.org/problem?id=1035 思路: 看到题目第一反应是用LCS ——最长公共子序列 来求解.因为给的字典比较多,最多有1w个,而LCS的算法时间复杂度是O( ...

  6. poj 1035 Spell checker(水题)

    题目:http://poj.org/problem?id=1035 还是暴搜 #include <iostream> #include<cstdio> #include< ...

  7. 【POJ】1035 Spell checker

    字典树. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib ...

  8. POJ 1035 Spell checker (模拟)

    题目链接 Description You, as a member of a development team for a new spell checking program, are to wri ...

  9. POJ 1035 Spell checker 简单字符串匹配

    在输入的单词中删除或替换或插入一个字符,看是否在字典中.直接暴力,172ms.. #include <stdio.h> #include <string.h> ]; ][], ...

随机推荐

  1. pydoc介绍

    Ka-Ping Yee 曾创建了一个相当著名的模块,名叫 pydoc (比较而言: pydoc 可以做到 perldoc 所能做的任何事,并且做得更好.更漂亮:-).对于 Python 2.1 来说, ...

  2. joomla对象注入漏洞分析

    0x00 漏洞简单介绍 jooomla 1.5 到 3.4.5 的全部版本号中存在反序列化对象造成对象注入的漏洞,漏洞利用无须登录,直接在前台就可以运行随意PHP代码. Joomla 安全团队紧急公布 ...

  3. 说说JSON和JSONP 也许你会豁然开朗

    说到AJAX就会不可避免的面临两个问题,第一个是AJAX以何种格式来交换数据?第二个是跨域的需求如何解决 前言 由于Sencha Touch 2这种开发模式的特性,基本决定了它原生的数据交互行为几乎只 ...

  4. Struts2_day04--课程介绍_Struts2拦截器概述&底层原理_重要的概念

    Struts2_day04 上节内容 今天内容 Struts2拦截器概述 拦截器底层原理 重要的概念 自定义拦截器 自定义登录拦截器 Struts2的标签库 Struts2表单标签(会用) Strut ...

  5. 传参方法:sharedApplication, NSUserDefaults, protocol 和 delegate(实例)

    本文转载至  http://blog.csdn.net/learnios/article/details/8442201 分类: 功能模块2012-12-27 10:22 109人阅读 评论(0) 收 ...

  6. JSP页面的生命周期

    JSP页面的生命周期:我们假设要访问的jsp页面是index.jsp.首先,用户发出请求index.jsp:服务器会判断是否是第一次请求:如果是的话,JSP引擎会把该JSP文件转换成为一个Servle ...

  7. UIWindow和UIScreen

    UIWindow和UIScreen 目录 概述 职责 实用操作 概述 UIWindow职责 包含了应用程序的可视化的内容 为视图和其他应用程序对象在触摸事件中提供了关键性的作用 与视图控制器一起协作来 ...

  8. 【BZOJ4071】[Apio2015]巴邻旁之桥 Treap

    [BZOJ4071][Apio2015]巴邻旁之桥 Description 一条东西走向的穆西河将巴邻旁市一分为二,分割成了区域 A 和区域 B. 每一块区域沿着河岸都建了恰好 1000000001 ...

  9. Android之內置、外置SDCard

    From:http://blog.csdn.net/u011290399/article/details/10363881 在项目中,发现通过Android提供的API获取外置SDCard的操作一直不 ...

  10. CentOS设置密码复杂度及过期时间等

    我们在使用linux系统设置密码的时候,经常遇到这样的问题,系统提示:您的密码太简单,或者您的密码是字典的一部分.那么系统是如何实现对用户的密码的复杂度的检查的呢? 系统对密码的控制是有两部分(我知道 ...