题目大意:原题链接

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. LoadRunner中winsocket协议学习

    首先让我们先看一下loadrunner- winsock 函数 一览表:        lrs_accept_connection 接受侦听套接字连接 lrs_close_socket 关闭打开的套接 ...

  2. HTTP报文-->MVC

    引用 学习Web开发不好好学习HTTP报文,将会“打拳不练功,到老一场空”,你花在犯迷糊上的时间比你沉下心来学习HTTP的时间肯定会多很多. HTTP请求报文解剖 HTTP请求报文由3部分组成(请求行 ...

  3. WPF 纯代码生成界面(不使用XAML)

    对于编写 WPF 应用程序,只是用代码进行开发而不使用任何 XAML 不是常见的方式(但是仍然完全支持).只使用代码进行开发的明显缺点是,有可能会使用编写 WPF 应用程序成为极端乏味的工作. WPF ...

  4. 论坛模块_版块管理_增删改查&实现上下移动

    论坛模块_版块管理1_增删改查 设计实体Forum.java public class Forum { private Long id; private String name; private St ...

  5. docker的私有仓库的搭建

    author: headsen chen date:2018-06-30  23:14:16 服务端(私有仓库:centos7_64位),使用端:centos6_64位 1.仓库的搭建: 安装dock ...

  6. ORA-12899: value too large for column

    ORA-12899: value too large for column "SOAU"."SJQY_QTSBSPEC"."PROPERTY_6&qu ...

  7. CodeForces 651 A Joysticks

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  8. CLR via 笔记4.2 类型转换 is 与 as 区别

    is 和 as 操作符是用来进行强制类型转换的 is : 检查一个对象是否兼容于其他指定的类型,并返回一个Bool值,永远不会抛出异常 object o = new object(); if (o i ...

  9. 购物车-删除单行商品-HTMLTableElement.deleteRow()

    wta 问题发源的代码: /*删除单行商品*/ function deleteRow(rowId){ var Index=document.getElementById(rowId).rowIndex ...

  10. VS调用python方法

    1.  安装python3.7 2.  Vs2010中配置python: 3.添加头文件:#include <Python.h> 4.问题:error LNK2001: 无法解析的外部符号 ...