Spell checker(串)
http://poj.org/problem?id=1035
题意:给定一个单词判断其是否在字典中,若存在输出"%s is correct",否则判断该单词删掉一个字母,或增加一个字母,或替换一个字母后是否存在于字典中。
#include<stdio.h>
#include<string.h>
int deal(char *s1,char *s2)
{
int i = ;
int len1 = strlen(s1);
int len2 = strlen(s2);
if(len1==len2)//替换
{
while(i < len1 && s1[i]==s2[i])
i++;
while(++i < len1)
{
if (s1[i]!=s2[i])
return ;
}
}
else if (len2-==len1)//添加
{
while(i < len1 && s1[i]==s2[i])
i++;
while(++i < len2)
{
if (s1[i-]!=s2[i])
return ;
}
}
else if (len2+==len1)//删除
{
while(i < len2 && s1[i]==s2[i])
i++;
while(++i < len1)
{
if (s1[i]!=s2[i-])
return ; }
}
else
return ;
return ;
}
int main()
{
char s1[][],s2[];
int i;
for (i = ;; i ++)
{
scanf("%s",s1[i]);
if (s1[i][]=='#')
break;
}
int n = i;
for (;;)
{
scanf("%s",s2);
if (s2[]=='#')
break;
for (i = ; i < n; i ++)
{
if (!strcmp(s1[i],s2))
{
printf("%s is correct\n",s2);
break;
}
}
if (i < n)
continue;
printf("%s:",s2);
for (i = ; i < n; i ++)
{
if(deal(s1[i],s2))
printf(" %s",s1[i]);
}
printf("\n");
}
return ;
}
Spell checker(串)的更多相关文章
- POJ 1035 Spell checker(串)
题目网址:http://poj.org/problem?id=1035 思路: 看到题目第一反应是用LCS ——最长公共子序列 来求解.因为给的字典比较多,最多有1w个,而LCS的算法时间复杂度是O( ...
- poj 1035 Spell checker
Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u J ...
- Spell checker
Spell checker Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Subm ...
- Spell checker(暴力)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 20188 Accepted: 7404 De ...
- POJ1035——Spell checker(字符串处理)
Spell checker DescriptionYou, as a member of a development team for a new spell checking program, ar ...
- poj 1035 Spell checker ( 字符串处理 )
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16675 Accepted: 6087 De ...
- [ACM] POJ 1035 Spell checker (单词查找,删除替换添加不论什么一个字母)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18693 Accepted: 6844 De ...
- POJ训练计划1035_Spell checker(串处理/暴力)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18418 Accepted: 6759 De ...
- Spell checker POJ 1035 字符串
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 25426 Accepted: 9300 De ...
- POJ 1035:Spell checker
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 22574 Accepted: 8231 De ...
随机推荐
- Codeforces_The least round way
B. The least round way time limit per test 2 seconds memory limit per test 64 megabytes input standa ...
- C#斐波那契数列方法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 【HTTP/S】透明代理、匿名代理、混淆代理、高匿代理有什么区别?
这4种代理,主要是在代理服务器端的配置不同,导致其向目标地址发送请求时,REMOTE_ADDR, HTTP_VIA,HTTP_X_FORWARDED_FOR三个变量不同. 1.透明代理(Transpa ...
- CAD把实体放到当前选择集中
主要用到函数说明: _DMxDrawX::AddCurrentSelect 把实体放到当前选择集中,详细说明如下: 参数 说明 LONGLONG lId 实体id VARIANT_BOOL isSho ...
- FTP服务器访问主动模式、被动模式
在公司里面,经常需要访问外网FTP取资料等情况.但是有时用windows界面访问经常遇到各种问题. 下面介绍两种客户端是如何访问ftp服务器. 首先我们需要说明:防火墙,是阻拦外界与内部的通讯的一道关 ...
- MySQL操作数据库和表的基本语句(DDL
1.创建数据库: CREATE DATABASE 数据库名; eg.CREATE DATABASE test_ddl;122.创建表 CREATE TABLE 表名(列名 数据类型 约束,...); ...
- JavaScript day2(变量)
变量(variable) 允许计算机以一种动态的形式来存储和操作数据,通过操作指向数据的指针而不是数据本身来避免了内存泄露,变量(Variable)的名字可以由数字.字母.$ 或者 _组成,但是不能包 ...
- 使用final关键字修饰一个引用类型变量时,是引用不能变,还是引用的对象不能变?
使用final关键字修饰一个引用类型变量时,是指引用变量不能变,引用变量所指向的对象中的内容还是可以改变的. 测试代码如下: package reviewTest; /** * @ClassName: ...
- homework week 1
第一周的作业 首先来完成第二个作业, 编写登录接口, 因为视频上并没有相关的教程, 就在网上搜了一下读写文件的语句, 粗略了解. f1 = open("data.txt",&quo ...
- 利用定时器 1和定时器0控制led1和led2分别 2hz和0.5hz闪烁
//利用定时器 1和定时器0控制led1和led2分别 2hz和0.5hz闪烁 #include<reg52.h> #define uchar unsigned char #define ...