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

Description

You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms.
If the word is absent in the dictionary then it can be replaced by correct words (from the dictionary) that can be obtained by one of the following operations: 
?deleting of one letter from the word; 
?replacing of one letter in the word with an arbitrary letter; 
?inserting of one arbitrary letter into the word. 
Your task is to write the program that will find all possible replacements from the dictionary for every given word. 

Input

The first part of the input file contains all words from the dictionary. Each word occupies its own line. This part is finished by the single character '#' on a separate line. All words are different. There will be at most 10000 words in the dictionary. 
The next part of the file contains all words that are to be checked. Each word occupies its own line. This part is also finished by the single character '#' on a separate line. There will be at most 50 words that are to be checked. 
All words in the input file (words from the dictionary and words to be checked) consist only of small alphabetic characters and each one contains 15 characters at most. 

Output

Write to the output file exactly one line for every checked word in the order of their appearance in the second part of the input file. If the word is correct (i.e. it exists in the dictionary) write the message: " is correct". If the word is not correct then write this word first, then write the character ':' (colon), and after a single space write all its possible replacements, separated by spaces. The replacements should be written in the order of their appearance in the dictionary (in the first part of the input file). If there are no replacements for this word then the line feed should immediately follow the colon.

Sample Input

i
is
has
have
be
my
more
contest
me
too
if
award
#
me
aware
m
contest
hav
oo
or
i
fi
mre
#

Sample Output

me is correct
aware: award
m: i my me
contest is correct
hav: has have
oo: too
or:
i is correct
fi: i
mre: more me

Source

 #include<stdio.h>
#include<string.h>
char st[][] ;
struct word_check
{
char src[] ;
bool flag ;
int cnt , no[] ;
}word[]; int k , f; void check ()
{
int diff ;
int ans ;
for (int i = ; i < f ; i++)
for (int j = ; j < k ; j++)
if (strcmp (word[i].src , st[j]) == ) {
word[i].flag = ;
} for (int i = ; i < f ; i++)
if (!word[i].flag)
for (int j = ; j < k ; j++) {
diff = strlen (word[i].src) - strlen (st[j]) ;
if (diff == ) {
ans = ;
for (int l = ; st[j][l] != '\0' ; l++) {
if (st[j][l] != word[i].src[l])
ans ++ ;
if (ans > )
break ;
}
if (ans == ) {
word[i].no [word[i].cnt] = j ;
word[i].cnt ++ ;
}
}
else if (diff == ) {
int a = ;
ans = ;
for (int l = ; word[i].src[l] != '\0' ; l++ , a++) {
if (st[j][a] != word[i].src[l]) {
ans ++ ;
a-- ;
}
if (ans > )
break ;
}
if (ans == ) {
word[i].no[word[i].cnt] = j ;
word[i].cnt ++ ;
}
}
else if (diff == -) {
int a = ;
ans = ;
for (int l = ; st[j][a] != '\0' ; l++ , a++) {
if (st[j][a] != word[i].src[l]) {
ans ++ ;
l-- ;
}
if (ans > )
break ;
}
if (ans == ) {
word[i].no[word[i].cnt] = j ;
word[i].cnt ++ ;
}
}
} for (int i = ; i < f ; i++) {
if (word[i].flag) {
printf ("%s is correct\n" , word[i].src) ;
}
else {
printf ("%s:" , word[i].src) ;
for (int j = ; j < word[i].cnt ; j++) {
printf (" %s" , st[word[i].no[j]]) ; }
//printf ("%d\n" , word[i].cnt) ;
printf ("\n") ;
}
}
} int main ()
{
// freopen ("a.txt" , "r" , stdin) ;
while (~ scanf ("%s" , st[])) {
k = ;
f = ;
getchar () ;
while () {
gets (st[++k]) ;
if (strcmp (st[k] , "#") == )
break ;
}
while () {
gets (word[f].src) ;
word[f].cnt = ;
f++ ;
if (strcmp (word[f - ].src , "#") == )
break ;
}
f-- ;
/* for (int i = 0 ; i < k ; i++)
printf ("%d " , word[i].flag) ;
puts ("");
for (int i = 0 ; i < f ; i++)
puts (word[i].src) ;*/
check () ;
}
return ;
}

Spell checker(暴力)的更多相关文章

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

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

  2. Spell checker

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

  3. poj 1035 Spell checker

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

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

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

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

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

  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. Code Spell Checker & VSCode 单词拼写验证

    Code Spell Checker & VSCode 单词拼写验证 https://marketplace.visualstudio.com/items?itemName=streetsid ...

  9. VSCode中插件Code Spell Checker

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

随机推荐

  1. [USACO2003][poj2018]Best Cow Fences(数形结合+单调队列维护)

    http://poj.org/problem?id=2018 此乃神题……详见04年集训队论文周源的,看了这个对斜率优化dp的理解也会好些. 分析: 我们要求的是{S[j]-s[i-1]}/{j-(i ...

  2. SpringMVC实现Restful风格的WebService

    1.环境 JDK7 MyEclipse2014 tomcat8 maven 3.3.3 spring4.1.4 2.创建maven工程 使用MyEclipse创建maven工程的方式可以参考这篇博文( ...

  3. 软工实践个人练习-使用github进行代码管理

    1.掌握使用Git进行代码版本,使用github进行代码托管. 2.创建小组Organization,并邀请组员进来. 3.将代码库https://github.com/sefzu2015/AutoC ...

  4. oracle 简述

    1.数据库有很多的管理工具,Sqlplus是最好的管理工具. 2.sql语句是学习中最难的部分,如何编写出高效的sql 语句是我们的目标 3.oracle的日常最终要的工作就是备份,永远是备份,有数据 ...

  5. [转]Java静态方法为什么不能访问非静态方法

    非静态方法(不带static)可以访问静态方法(带static),但是反过来就不行,为什么呢? ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 publi ...

  6. publish_subscribe

    <!DOCTYPE html> <html> <head> <title></title> </head> <body&g ...

  7. hdu4825 字典树 XOR

    用字典树思想来做.对于一个数,给出他的二进制,然后更具二进制建立字典树,然后每次询问的时候的数也给出二进制,如果当前为1,那就向0走,为0,向1走. #include<stdio.h> # ...

  8. 警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:CurrencyClientServe

    有的说: 在Servers视图里双击创建的server,然后在其server的配置界面中选中"Publish module contexts to separate XML files&qu ...

  9. jquery 插件之 点赞“+1” 特效

    一般用户点个赞后,都会有个 +1 的特效飘过,用户已经点过赞了,会有“已点过赞”的特效提示 在这里,我们写了一个点赞的插件 //扩展对象点赞插件.点赞特效 //用法:jQuery('.praisebt ...

  10. Oracle 11g 默认用户名和密码

    安装ORACLE时,若没有为下列用户重设密码,则其默认密码如下: 用户名 / 密码                      登录身份                              说明 ...