poj1035Spell checker
暴力解决。
先把字典里的每一个单词的长度存起来。在查找的时候。就比較长度,在多一个少一个之间找,
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<queue>
using namespace std;
char s[10005][20];
char h[20];
int w[10005],len;
int show(int a)
{
int i,t,k;
int bu=0;
t=w[a]-len;
if(t>1)
return 1;
if(t==0)
{
for(i=0;i<w[a];i++)
{
if(h[i]!=s[a][i])
{bu++;}
}
if(bu==1)
return 0;
}
else
{
if(t==1)
{
for(i=0,k=0;i<w[a];)
{
if(h[k]!=s[a][i])
{bu++;i++;}
else
{
i++;k++;
}
}
if(bu==1)
return 0;
}
else
if(t==-1)
{
for(i=0,k=0;k<len;)
{
if(h[k]!=s[a][i])
{bu++;k++;}
else
{
i++;k++;
}
}
}
if(bu==1)
return 0;
}
return 1;
}
int main()
{
int i=0;
while(scanf("%s",&s[i]))
{
if(s[i][0]=='#')
break;
w[i]=strlen(s[i]);
i++;
}
i--;
int j;
while(scanf("%s",h))
{
if(h[0]=='#')
break;
printf("%s",h);
len=strlen(h);
// printf("%d ,%s",i,s[0]);
for(j=0;j<=i;j++)
{
if(w[j]==len&&strcmp(s[j],h)==0)
{printf(" is correct\n");
break;}
}
if(j>i)
{
printf(":");
for(j=0;j<=i;j++)
if(show(j)==0) printf(" %s",s[j]);
printf("\n");
}
}
return 0;
}
poj1035Spell checker的更多相关文章
- XPath Checker和Firebug安装与使用
一.XPath Checker和Firebug简介 XPath Checker和Firebug是写爬虫过程中提取数据的非常有用的插件工具,直接打开火狐浏览器的菜单就可以下载 二.XPath Check ...
- firefox安装firebug\XPath Checker
XPath Checker安装,打开下面地址安装: https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/ 安装XPath Chec ...
- hihocoder #1341 Constraint Checker
传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given a set of constraints like 0<N<=M<=100 and ...
- Spell checker
Spell checker Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Subm ...
- EBS Technology Codelevel Checker (ETCC)
ETCC提供了两个脚本,用来帮助用户检测 E-Business Suite Release 12.2数据库和中间层是否安装了必须的补丁.官方强烈推荐使用. 1.checkDBpatch.sh 这个脚本 ...
- poj 1035 Spell checker
Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u J ...
- [USACO 1.5.4]checker(水题重做——位运算(lowbit的应用))
描述 检查一个如下的6 x 6的跳棋棋盘,有六个棋子被放置在棋盘上,使得每行.每列有且只有一个,每条对角线(包括两条主对角线的所有平行线)上至多有一个棋子. 0 1 2 3 4 5 6 ------- ...
- Spell checker(暴力)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 20188 Accepted: 7404 De ...
- 【USACO】checker
一看题目 经典的8皇后问题 不过是皇后数量可变而已 不用想 回溯法. 需要个生成每次可选择序列的函数, 在存储可选择的序列时按照先大后小的顺序排的.这样每次找最小和去掉最小都很方便,只要有个记录数量的 ...
随机推荐
- c17---指针
// // main.c // 指针基本概念 #include <stdio.h> // 基本数据类型作为函数的参数是值传递, 在函数中修改形参的值不会影响到外面实参的值 void cha ...
- c16---字符串
// // main.c // 字符串的基本概念,字符串和字符数组的共用的char[], #include <stdio.h> int main(int argc, const char ...
- linux下的开源移动图像监测程序--motion编译与配置【转】
本文转载自:http://www.cnblogs.com/qinyg/p/3355707.html 前几天在网上偶然看到一篇博客,是利用linxu下的开源的motion搭建嵌入式视频动态监控系统,感觉 ...
- B1012 [JSOI2008]最大数maxnumber 分块||RMQ
这个题有毒,卡最大值...我开1 << 30爆零让我以为我分块错了...gg,然后去写RMQ,但是这个题st表是真简单啊.后来刘胜与巨佬一眼看出来我最大值不够大...然后1LL<&l ...
- [HTML] 如何使用robots.txt防止搜索引擎抓取页面
Robots.txt 文件对抓取网络的搜索引擎漫游器(称为漫游器)进行限制.这些漫游器是自动的,在它们访问网页前会查看是否存在限制其访问特定网页的 robots.txt 文件.如果你想保护网站上的某些 ...
- 什么是递归?用十进制转二进制的Python函数示例说明
先上用Python写的十进制转二进制的函数代码: def Dec2Bin(dec): result = '' if dec: result = Dec2Bin(dec//2) return resul ...
- 4、Collection接口功能测试(所有的All方法)
package cn.itcast_01; import java.util.ArrayList; import java.util.Collection; /* * 所有带All的方法:(听完就忘) ...
- Unity3d gameObject
using UnityEngine; using System.Collections; public class test : MonoBehaviour { //print只能在MonoBehav ...
- 第6章 服务模式 在 .NET 中实现 Service Interface
上下文 您 的应用程序部署在 Microsoft Windows? 操作系统上.您决定将应用程序的某一块功能作为 ASP.NET Web Service 公开.互操作性是一个关键问题,因此您无法使用仅 ...
- max 宏定义取消:error C2589: error C2059: 语法错误 : “::”
原文链接:http://blog.csdn.net/danelumax2/article/details/9172465有修改! 一:关于Pcl和WIndef的冲突: 1. 错误输出 ./zlibra ...