题意:

    此题是一个字符串的问题,首先要给出一个字典,里面存储了数个单词。而后,给出一个单词,如果字典中存在,那么就输出correct,如果字典中没有,那么就要判断是不是这个单词有错误,错误有3种,第一种是单词种的一个字母写错了,就是和字典中的单词来说只有一个字母不同,第二种是单词多了一个字母,如果去掉该字母,则和字典中的某单词一致。第三种是单词少一个字母,如果添加上该字母,则和字典中的某单词一致。目的是输出这几种错误所对应的字典中的单词。
 
暴力求解超时!!!
#include<cstdio>
#include<iostream>
#include<cstring>
#define M 10010
#define N 15
using namespace std;
char ch[M][N],s[N];
int a[M];
int search(char *a,char *b)
{
int lena=strlen(a);
int lenb=strlen(b);
if(lena==lenb)
{
int flag=;
for(int i=;i<lena;i++)
if(a[i]!=b[i])
if(!flag) flag=;
else return ;
if(flag==)return ;
}
if(lena==lenb+)
{
int pa=,pb=,flag=;
while()
{
if(pa>=lena&&pb>=lenb)break;
if(a[pa]==b[pb])
{
pa++;
pb++;
}
else
if(!flag)
{
flag=;
pa++;
}
else return ;
}
if(flag==)return ;
}
if(lena==lenb-)
{
int pa=,pb=,flag=;
while()
{
if(pa>=lena&&pb>=lenb)break;
if(a[pa]==b[pb])
{
pa++;
pb++;
}
else
if(!flag)
{
flag=;
pb++;
}
else return ;
}
if(flag==)return ;
}
return ;
}
int main()
{
int n=;
while()
{
scanf("%s",ch[++n]);
if(ch[n][]=='#')
{
n--;
break;
}
}
while()
{
int flag=,cnt=;
scanf("%s",s);
if(s[]=='#')break;
printf("%s",s);
for(int i=;i<=n;i++)
{
if(strcmp(s,ch[i])==)
{
printf(" is correct\n");
flag=;
break;
}
else if(search(s,ch[i]))
a[++cnt]=i;
}
if(!flag)
{
printf(":");
for(int i=;i<=cnt;i++)
printf(" %s",ch[a[i]]);
printf("\n");
}
}
return ;
}

Spell checker(poj 1035)的更多相关文章

  1. POJ 1035 Spell checker (模拟)

    题目链接 Description You, as a member of a development team for a new spell checking program, are to wri ...

  2. Spell checker(串)

    http://poj.org/problem?id=1035 题意:给定一个单词判断其是否在字典中,若存在输出"%s is correct",否则判断该单词删掉一个字母,或增加一个 ...

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

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

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

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

  5. poj 1035 Spell checker

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

  6. Spell checker POJ 1035 字符串

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

  7. POJ 1035:Spell checker

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

  8. POJ 1035 代码+具体的目光

    Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19319 Accepted: 7060 Descri ...

  9. VSCode中插件Code Spell Checker

    说在前面 介绍 Code Spell Checker 是在VSCode中的一款插件,能够帮助我们检查单词拼写是否出现错误,检查的规则遵循 camelCase (驼峰拼写法). 安装方法 打开VSCod ...

随机推荐

  1. HDU 1285 确定比赛名次

    传送门 确定比赛名次 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  2. codeforce 626E(二分)

    E. Simple Skewness time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  3. jmap命令详解

    1.命令基本概述 Jmap是一个可以输出所有内存中对象的工具,甚至可以将VM 中的heap,以二进制输出成文本.打印出某个java进程(使用pid)内存内的,所有‘对象’的情况(如:产生那些对象,及其 ...

  4. hibernate提供的5种检索数据方式

    一.五种检索数据方式 1.OID检索,即使用session.get或session.load通过类及指定id查询数据,如Customer c=(Customer)session.get("C ...

  5. find只查当前目录 和 -exec和xargs区别

    1.find默认查找当前目录和子目录,通过maxdepth限制只查当前目录: find . -maxdepth 1 -type f -name "*.php" 2. find . ...

  6. centos7 nginx用systemctl方式管理的脚本

    vim /usr/lib/systemd/system/nginx.service [Unit] Description=nginx - high performance web server Doc ...

  7. mysql字符串截取

    mysql字符串截取 update zcat ) where lev1 is null; update zcat ) where lev2 is null; 函数: 1.从左开始截取字符串 left( ...

  8. Array和ArrayList互相转换

    class Order{ public string orderId; public string orderName; public decimal orderPrice; } public cla ...

  9. Matlab图像处理入门

    1. Matlab基础 1.1     数据格式 Matlab默认的数据格式为双精度浮点数的矩阵或数组,同时支持其它数据类型.Matlab将单变量看作1´1的数组.Matlab支持的数据类型如下: 索 ...

  10. xpath基础知识

    相关链接: http://www.ruanyifeng.com/blog/2009/07/xpath_path_expressions.html 自动生成xpath的工具: http://blog.s ...