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 ...
随机推荐
- Building microservices with Spring Cloud and Netflix OSS, part 2
In Part 1 we used core components in Spring Cloud and Netflix OSS, i.e. Eureka, Ribbon and Zuul, to ...
- iphone开发第一个UI应用程序QQ
#import <UIKit/UIKit.h> @interface HViewController : UIViewController @property (retain, nonat ...
- 【CSDN人物访谈】蒋守壮分享他的技术成长之路以及对Hive技术的解读与思考
结缘大数据技术 CSDN:请简单地介绍一下自己. 蒋守壮:首先非常感谢CSDN能够给我这次被专访的机会,可以让我重新审视自己的职业发展历程,也希望能够帮助一些同行的朋友们.目前就职万达网络科技集团有限 ...
- PowerDesigner 非数值默认值时会自动增加单引单
在PowerDesigner中,如果默认值是非数值型的,那么 PowerDesigner 会默认加上单引号 因此我们需要把这个默认的单引号干掉,如果是需要设置字符串默认值的时候,就手工加上 单引号 即 ...
- EXTJS 4.2 添加滚动条
bodyStyle: 'overflow-x:hidden; overflow-y:scroll',//显示滚动 文章来源:http://www.cnblogs.com/exmyth/archive/ ...
- XSS 复合编码 续
对上文 [web安全]第二弹:XSS攻防中的复合编码问题 的一些补充,思路来源于:http://escape.alf.nu/3/ html解码的问题: 通过appendChild添加的节点,不会被HT ...
- 【BZOJ 1054】 [HAOI2008]移动玩具
Description 在一个4*4的方框内摆放了若干个相同的玩具,某人想将这些玩具重新摆放成为他心中理想的状态,规定移动时只能将玩具向上下左右四个方向移动,并且移动的位置不能有玩具,请你用最少的移动 ...
- 第三方登录过程—OAuth2.0协议
---恢复内容开始--- 理清思路 1.在第三方注册成为开发者,拿到第三方给的client_id(app_id---就像你的身份证.QQ号)和client_secret(就像你的QQ密码): 2.填写 ...
- XSD - <schema> 元素
<schema> 元素 <schema> 元素是每一个 XML Schema 的根元素: <?xml version="1.0"?> <x ...
- [Database]Operators
Arithmetic Operators +,-,×,÷ Comparison Operators =,<>,!=,>,<,>=,<= BETWEEN,IN,IS ...