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. Sublime Text 2 使用笔记(大全呀,菜鸟必看)

    下载和安装 Sublime Text2是一款开源的软件,不需要注册即可使用(虽然没有注册会有弹窗,但是基本不影响使用). 下载地址:http://www.sublimetext.com ,请自行根据系 ...

  2. [USACO]6.1.3 cow xor(二进制+Trie)

    题意:给你一个序列(n<=100000),求出一个连续的子序列[i,j]使得ai xor ai+1 xor…… xor aj最大,求出这个最大值(其中每个数<=2^21) 分析:题目和求一 ...

  3. js获取url查询参数

    function getURLParamInfo(key) { if (location.search == "") { return undefined; } var a = l ...

  4. iOS开发小技巧--父子控制器练习中get到的技能,控制核心动画的范围

    一.未经过处理的动画是这样的,自定义的导航按钮也一起跟着转起来了. 二.自己想要的效果 三.实现这种效果的思想:核心动画要添加到view的layer上面,刚开始的情况是讲核心动画添加到了整个大view ...

  5. poj3692 最大点权独立集/最大独立集

    题意:有男孩和女孩,男孩之间全部认识,女孩之间全部认识,一部分男孩和女孩认识,现在希望选出一些孩子,这些孩子都相互认识. 方法:正的做不好做,观察他的补图,补图之间无关系的边就是原图有关系的.补图中的 ...

  6. Yii2 radioList设置默认值

    可以在对应的Controller的action中设置 $model->type = 1; 在view中 <?php $form = ActiveForm::begin(); ?>   ...

  7. DEDECMS数据库执行原理、CMS代码层SQL注入防御思路

    我们在上一篇文章中学习了DEDECMS的模板标签.模板解析原理,以及通过对模板核心类的Hook Patch来对模板的解析流量的攻击模式检测,达到修复模板类代码执行漏洞的目的 http://www.cn ...

  8. POJ2531Network Saboteur(DFS+剪枝)

    Network Saboteur Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10391   Accepted: 4990 ...

  9. css中的id和css的区别

    在样式表定义一个样式的时候,可以定义id也可以定义class. 1.在CSS文件里书写时,ID加前缀"#":CLASS用"." 2.id一个页面只可以使用一次: ...

  10. JSTL标签库简介

    核心标签库 http://java.sun.com/jsp/jstl/core <c:catch>,<c:url>的使用 <!-- 捕获异常 --> <c:c ...