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. Go 时间相关

    >获取当前时间: t := time.Now() >获取当天开始.结束时间: tm1 := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, ...

  2. python mongodb压力测试脚本

    $ pip install pymongo #!/usr/bin/env python #coding=utf-8 #Author: Ca0Gu0 from pymongo import MongoC ...

  3. unittest 是什么?怎么用?

    unittest单元测试框架详解 https://www.cnblogs.com/fighter007/p/8245063.html unittest最详细的解说 https://www.cnblog ...

  4. c#中动态创建textbox并且从数据库中获取表中数据添加到textbox中

    private void FormLugOther_Load(object sender, EventArgs e) { foreach (string str in FormLug.FieldLis ...

  5. Sending Secret Messages LightOJ - 1404

    Sending Secret Messages LightOJ - 1404 Alice wants to send Bob some confidential messages. But their ...

  6. Tomcat启动失败--Several ports (8005, 8080, 8009)

    启动Tomcat服务器报错: Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are alre ...

  7. 关于read和fread

    1.fread与read的区别---open和fopen的区别--fread函数和fwrite函数:http://blog.csdn.net/dreamtdp/article/details/7560 ...

  8. windows桌面远程工具连接Ubuntu

    1.Ubuntu安装:sudo apt-get install xrdp    sudo apt-get install vnc4server sudo apt-get install xubuntu ...

  9. java常见知识

    在JSP页面获取当前项目名称的方法: 方法1: <%= this.getServletContext().getContextPath() %> 方法2: 使用EL表达式 ${pageCo ...

  10. Python与常见加密方式

    前言 我们所说的加密方式,都是对二进制编码的格式进行加密的,对应到Python中,则是我们的Bytes. 所以当我们在Python中进行加密操作的时候,要确保我们操作的是Bytes,否则就会报错. 将 ...