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. 批量注释LOG

    sed -i "s/LOG/\/\/ LOG/g" `grep LOG\(TRACE\) -rl .`

  2. lamlmzhang的新博客开通了,欢迎大家的关注

    从这里开始lamlmzhang的java开发之路~!

  3. STL_优先队列_(转载)

    转自:http://www.cnblogs.com/summerRQ/articles/2470130.html STL容器之优先队列 优先级队列,以前刷题的时候用的比较熟,现在竟然我只能记得它的关键 ...

  4. 如何使用 Python 创建一名可操控的角色玩家

    在 这个系列的第一篇文章 中,我解释了如何使用 Python 创建一个简单的基于文本的骰子游戏.在第二部分中,我向你们展示了如何从头开始构建游戏,即从 创建游戏的环境 开始.但是每个游戏都需要一名玩家 ...

  5. js 图表转图片

    最近项目上有个需求,是将一些teechart做的图表转换成图片插入自动生成的PDF里,Teechart绘图和如何生成PDF这些这里就不说了,这个任务比较别扭的一点是,图表自动生成,且整个过程中页面不能 ...

  6. ES6学习历程(字符串的扩展)

    字符串的扩展 在看这一节的时候前半部分写的都是关于unicode的内容,我个人感觉这部分在实际的开发中用的很少,所以不打算在做记录,等届时用到再有针对性的看,所以就将在ES6里面关于字符串操作的一些新 ...

  7. (蓝桥杯)第八届A组C/C++跳蚱蜢

    #include<iostream> #include<memory.h> #include<stack> #include<string> #incl ...

  8. 第七节:pandas排序

    pandas具有两种排序方式:sort_index()和sort_values().

  9. Codeforces 912D - Fishes

    传送门:http://codeforces.com/contest/912/problem/D 本题是一个概率问题——求数学期望. 在一个n×m的方格中,有k个“*”.每个格子里可能有0~1个“*”. ...

  10. SRPING MVC基本配置

    作下记录,WEB.XML的配置及DispatcherServlet-context.xml的配置. 而后者的配置,有不同的形式,不要被迷惑. WEB.XML <servlet> <s ...