题目: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(水题)的更多相关文章

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

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

  2. poj 1035 Spell checker

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

  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(hash)

    题目链接:http://poj.org/problem?id=1035 思路分析: 1.使用哈希表存储字典 2.对待查找的word在字典中查找,查找成功输出查找成功信息 3.若查找不成功,对word增 ...

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

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

  6. POJ 1035 Spell checker(串)

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

  7. POJ 1035 Spell checker (模拟)

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

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

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

  9. POJ 1488 Tex Quotes --- 水题

    POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...

随机推荐

  1. ajax分页效果实现

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  2. CentOS 6.4 中安装部署 Nutch 1.7

    1.配置SSH 自行查阅相关资料 2.安装JDK,配置Java环境 自行查阅相关资料 3.安装SVN [root@master ~]# yum install -y subversion 通过SVN签 ...

  3. apache、php隐藏头信息的方法

    本文介绍下,在apache与php中隐藏头部信息的方法,有需要的朋友参考下. 一.apache隐藏头部信息 apache 的 httpd.conf 有两个配置可以控制是否显示服务器信息给用户.Serv ...

  4. Spark机器学习 Day1 机器学习概述

    Spark机器学习 Day1 机器学习概述 今天主要讨论个问题:Spark机器学习的本质是什么,其内部构成到底是什么. 简单来说,机器学习是数据+算法. 数据 在Spark中做机器学习,肯定有数据来源 ...

  5. 关于yum与源码安装的LAMP或LNMP网页直接显示空白页的问题?

    学习LAMP.LNMP时,遇到很奇怪的问题就是:搭建完LAMP或LNMP环境后安装PHPweb程序时,Discuz和Wordpress打不开安装向导,直接显示空白页(PHPWind9.0除外),没有任 ...

  6. FFT Golang 实现

    最近项目要用到快速傅立叶变换,自己写了个算法,测试了下,性能和精度还可以接受 len,time= 1048576 378.186167ms diff=-0.00000000000225974794 I ...

  7. 1062 Talent and Virtue (25)

    /* L (>=60), the lower bound of the qualified grades -- that is, only the ones whose grades of ta ...

  8. opencv学习笔记(03)——遍历图像(迭代器法)

    #include <opencv2\highgui\highgui.hpp> #include <opencv2\imgproc\imgproc.hpp> #include & ...

  9. 开源CMS的忠实粉丝——We7

    说到开源CMS这个词,首先来说一下什么是开源,因为很多人可能会存在一个误区,开源就是免费使用,其实不然.开源产品,从事软件开发的专业人士都很清楚,开源就是开发源码,是把一个软件的开发过程中的技术结构, ...

  10. Mysql 配置主从服务自动同步功能

    1.修改主服务器master:   #vi /etc/my.cnf       [mysqld]       log-bin=mysql-bin   //[必须]启用二进制日志       serve ...