poj 1035 Spell checker(水题)
题目:http://poj.org/problem?id=1035
还是暴搜
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<stack>
#include<queue>
#include<iomanip>
#include<cmath>
#include<map>
#include<vector>
#include<algorithm>
using namespace std; char s[][],str[],a[][];
int main()
{
int i,j,f,n,x,k,cnt,y;
for(i=; ; i++)
{
scanf("%s",s[i]);
if(strcmp(s[i],"#")==)
break;
}
n=i;
while()
{
f=;
cnt=;
y=;
scanf("%s",str);
if(strcmp(str,"#")==)
break;
for(i=; i<n; i++)
{
if(strcmp(s[i],str)==)
{
printf("%s is correct\n",str);
y=;
break;
}
}
if(y==)
{
for(j=; j<n; j++)
{
if((strlen(s[j])-strlen(str))==)
{
x=;
for(i=,k=; i<strlen(s[j]),k<strlen(str); k++,i++)
{
while(s[j][i]!=str[k]&&(k<strlen(str))&&(i<strlen(s[j])))
{
if(x==)
i++;
if(x!=)
k++;
x++;
}
}
if(x<=)
{
f=;
strcpy(a[cnt++],s[j]);
}
}
if((strlen(s[j])-strlen(str))==-)
{
x=;
for(i=,k=; i<strlen(s[j]),k<strlen(str); k++,i++)
{
while(s[j][i]!=str[k]&&(k<strlen(str))&&(i<strlen(s[j])))
{
if(x==)
k++;
if(x!=)
i++;
x++;
}
}
if(x<=)
{
f=;
strcpy(a[cnt++],s[j]);
}
}
if((strlen(s[j])-strlen(str))==)
{
x=;
for(i=,k=; i<strlen(s[j]),k<strlen(str); k++,i++)
{
if(s[j][i]!=str[k])
{
x++;
}
}
if(x==)
{
f=;
strcpy(a[cnt++],s[j]);
}
}
}
printf("%s:",str);
if(f)
for(i=; i<cnt; i++)
{
printf(" ");
printf("%s",a[i]);
} printf("\n");
}
}
return ;
}
poj 1035 Spell checker(水题)的更多相关文章
- poj 1035 Spell checker ( 字符串处理 )
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16675 Accepted: 6087 De ...
- poj 1035 Spell checker
Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u J ...
- [ACM] POJ 1035 Spell checker (单词查找,删除替换添加不论什么一个字母)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18693 Accepted: 6844 De ...
- poj 1035 Spell checker(hash)
题目链接:http://poj.org/problem?id=1035 思路分析: 1.使用哈希表存储字典 2.对待查找的word在字典中查找,查找成功输出查找成功信息 3.若查找不成功,对word增 ...
- 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 (模拟)
题目链接 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> ]; ][], ...
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
随机推荐
- 如何保证写出来的程序没BUG
- 转发 PHP 资料(一)
WebShell隐藏思路.webshell磁盘读写动态检测.webshell沙箱动态检测(2) 作为WebShell检测.CMS修复.WebShell攻防研究学习的第二篇文章 本文旨在研究Webs ...
- linux内核编译,内核参数修改
核心(kernel):/boot/vmlinuz-version version 带发行包版本,本地版本内核模块(kernel object): /lib/modules/version/ 内核设计: ...
- delphi xe memory leak produced in WSDLLookup.pas
constructor TWSDLLookup.Create; begin FLookup := TDictionary<string, Variant>.Create; end; des ...
- 【转】 Linux Core Dump 介绍
=============================================================== Linux core dump的祥细介绍和使用 =========== ...
- cmd&Linux 下使用mysql全记录
php mysql数据库常用cmd命令集 show databases; 显示数据库 create database name; 创建数据库 use databasename; 选择数据库 drop ...
- poi导出到excel步骤分析
在没用过poi之前感觉poi是很高大上的样子, 项目中用了发现poi的代码重复性很高类似于jdbc的模板代码, 项目中如果大量使用最好封装起来; 总结一下归结为6步 1 打开或新创建一个工作薄(使用H ...
- 正则表达式通过Unicode属性匹配
原文链接:http://zochen.iteye.com/blog/690716 Unicode 编码并不只是为某个字符简单定义了一个编码,而且还将其进行了归类. \pP 其中的小写 p 是 prop ...
- 1194: [HNOI2006]潘多拉的盒子 - BZOJ
Description Input 第一行是一个正整数S,表示宝盒上咒语机的个数,(1≤S≤50).文件以下分为S块,每一块描述一个咒语机,按照咒语机0,咒语机1„„咒语机S-1的顺序描述.每一块的 ...
- [转载]js 遍历数组对象
有一个JSON数组如下 all = {"error":0,"content":[{"name":"北京","v ...