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(串)的更多相关文章

  1. POJ 1035 Spell checker(串)

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

  2. poj 1035 Spell checker

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

  3. Spell checker

     Spell checker Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Subm ...

  4. Spell checker(暴力)

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 20188   Accepted: 7404 De ...

  5. POJ1035——Spell checker(字符串处理)

    Spell checker DescriptionYou, as a member of a development team for a new spell checking program, ar ...

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

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

  7. [ACM] POJ 1035 Spell checker (单词查找,删除替换添加不论什么一个字母)

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18693   Accepted: 6844 De ...

  8. POJ训练计划1035_Spell checker(串处理/暴力)

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18418   Accepted: 6759 De ...

  9. Spell checker POJ 1035 字符串

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25426   Accepted: 9300 De ...

  10. POJ 1035:Spell checker

    Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22574   Accepted: 8231 De ...

随机推荐

  1. mysql_数据查询_嵌套查询

    嵌套查询 一个SELECT-FROM-WHERE语句称为一个查询块. 嵌套查询:将一个查询块嵌套在另一个查询块的WHERE子句或者HAVING短语的条件中的查询. 注:子查询的SELECT语句中不能使 ...

  2. Python 之字符串操作

    # capitalize()将字符串的第一个字符转换为大写 # center(width, fillchar)返回一个指定的宽度 width 居中的字符串,fillchar 为填充的字符,默认为空格. ...

  3. 如何在mac里面,把xcode代码同步到 tfs 的 git库(新git库)

    克隆篇请参考:http://www.cnblogs.com/IWings/p/6744895.html 在mac安装visual studio code https://code.visualstud ...

  4. CAD绘一个文字自动剧中的标注 (com接口)

    主要用到函数说明: _DMxDrawX::DrawDimRotated 绘制一个线型标注.详细说明如下: 参数 说明 DOUBLE dExtLine1PointX 输入第一条界线的起始点X值 DOUB ...

  5. 云计算时代,你为什么一定要学Linux?

    云计算早已不是什么稀奇的概念,它的火爆让Linux运维工程师这个职业越来越重要.在当今各类云平台提供的系统中,Linux系统几乎毫无争议的独占鳌头,市场份额进一步扩张. 这也让Linux运维工程师职位 ...

  6. Django - 获取表单数据的三种方式

    1.query set 对象 2.字典 3.query set 元组 备注:对象通过 ”对象.列名"方式访问,元组通过“对象.索引”方式访问.

  7. 在引入的css或者js文件后面加参数的作用

    有时候可能会遇到js或者css文件引用后传递参数: css和js带参数(形如.css?v=与.js?v=) <script type=”text/javascript” src=”jb51.js ...

  8. 机器学习中jupyter lab的安装方法以及使用的命令

    安装JupyterLab使用pip安装: pip install jupyterlab# 必须将用户级目录添加 到环境变量才能启动pip install --userbinPATHjupyter la ...

  9. python常用三方库 - openpyxl

    目录 python常用三方库 - openpyxl 读取Excel文件 写入Excel文件 python常用三方库 - openpyxl openpyxl是一个第三方库, 可以处理xlsx格式的Exc ...

  10. 【codeforces 509C】Sums of Digits

    [题目链接]:http://codeforces.com/contest/509/problem/C [题意] 给你一个数组b[i] 要求一个严格升序的数组a[i]; 使得a[i]是b[i]各个位上的 ...