题目: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. jQueryr .on方法解析

    .On() 其实.bind(), .live(), .delegate()都是通过.on()来实现的,.unbind(), .die(), .undelegate(),也是一样的都是通过.off()来 ...

  2. centos架设FTP服务器

    1.安装vsftp在这里,我们架设的是虚拟用户,所谓虚拟用户就是没有使用真实的帐户,只是通过某种手段达到映射帐户和设置权限的目的.yum -y install vsftpd在CentOS中,这样就可以 ...

  3. ECSHOP添加购物车加图片飞入效果

    为ECSHOP的添加购物车,加入图片飞入效果. 首先: 在goods.dwt中查找添加购物车按钮: 为添加购物车按钮加上id: 例如: <a id="iproduct_{$goods. ...

  4. C#网络编程简单实现通信小例子-1

    1.主界面 2.源程序 Send public partial class formUdpSend : Form { //声明一个UdpClient对象 UdpClient udpClient; pu ...

  5. LINQ to XML学习笔记

    一.XML基础知识 1.XML:可扩展标记语言 Extensible Markup Language ,提供了一种保存数据的格式,数据可以通过这种格式很容易地在不同的应用程序之间实现共享. 2.使用X ...

  6. c# Oracle 远程连接方式 plsql 连接oracle 11g 64位

    1.本地连接字符串:   string connect = "Data Source=orcl;user=XXX;password=XXX;Persist Security Info=Tru ...

  7. ios 保存本地数据的方法

    1. NSString *path = [[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"plist" ...

  8. 链接Eclipse和SQL SEVER

    一.本文内容 讲诉使用JDBC建立Eclipse和Sql sever的桥梁的过程与其中可能遇见的问题. 二.详细内容 1.JDBC驱动的下载 建议一定要上与SQL SEVER相关的微软官网下载,以便找 ...

  9. java第五课:方法

    方法交换位置的三个步骤:1.把第一个盒子里的东西拿出来,放到一边2.把第二个盒子里的东西放到第一个盒子里3.捡起刚刚放到一边的东西,放到第二个盒子里 值传递:实际参数将内部保存的值,复制给方法的参数. ...

  10. CSS3新的字体尺寸单位rem

    CSS3引入新的字体尺寸单位 rem ,可以简单记忆为root rm. CSS3的出现,他同时引进了一些新的单位,包括我们今天所说的rem.在W3C官网上 是这样描述rem的——“font size ...