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 ...
随机推荐
- Angular之【form提交问题】
前端页面是这样: <form class="form-horizontal" role="form" name="LoginForm" ...
- android 打开GPS的几种方式
1.在讨论打开gps的之前先看下如何检测gps的开关情况: 方式一: boolean gpsEnabled = locationManager.isProviderEnabled(LocationMa ...
- [PHP]set_time_limit — 设置脚本最大执行时间
(PHP 4, PHP 5) set_time_limit — 设置脚本最大执行时间 说明 void set_time_limit ( int $seconds ) 设置允许脚本运行的时间,单位为秒. ...
- 关于B/S系统中文件上传的大小限制怎么做
1.前端:采用flash控件或者Html5的特性(有浏览器版本要求)来判断文件大小.纯html或js是没法判断用户上传文件大小的. 2.nginx:服务器端的第一道防线,一般会有对上传文件做大小限制. ...
- NULL, NUL, EOF, '\0',0区别
NULL: 定义为0或0L或(void *)0,用于指示一个指针值是空,即什么都不指:'\0': 用且只用字符串结束符;NUL : 0x00,0值字符,可以用于结束ASCII字符串,和'\0'类似,但 ...
- MyEclipse新建Maven工程
1.File-->New-->Web Project 2.新建文件夹 需要新建4个源文件夹,分别是 src/main/java src/main/resources src/te ...
- 巧用九宫格以减少UI资源量
UI资源量对资源包大小和内存的影响 UI资源具有以下特点: (1)UI资源几乎都是图片,而图片是最占资源量的资源类型之一. (2)Unity不支持外部压缩,即使在外部将一个10MB的图片压缩到只剩1M ...
- (转载)猫都能学会的Unity3D Shader入门指南(一)
原文地址 http://onevcat.com/2013/07/shader-tutorial-1/ 动机 自己使用Unity3D也有一段时间了,但是很多时候是流于表面,更多地是把这个引擎简单地用作脚 ...
- how to get sharepoint lookup value
SPFieldLookup lookUp1 = properties.ListItem.ParentList.Fields.GetField("Leave_x0020_Type") ...
- TF/IDF计算方法
FROM:http://blog.csdn.net/pennyliang/article/details/1231028 我们已经谈过了如何自动下载网页.如何建立索引.如何衡量网页的质量(Page R ...