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. 给 Xamarin.Form For Windows Phone APP 加个漂亮的 "头"

    Windows Phone 是那个1%, 我也是那个1%, 不喜勿喷.WP 向来给 android / ios 的粉们一个最直观的印象: 丑.其实"丑"这个东西会一直下去,而且是个 ...

  2. 我给出的一份Java服务器端面试题-适合电话面试

    这部分内容,参考了<面试官的七种武器>一文. 电面与face2face的面试还是有区别的,很多考察方式无法使用. 从简历聊起,逐渐进入正题. Java语法 重载与重写的区别? java如何 ...

  3. 数据结构之链表C语言实现以及使用场景分析

    牢骚:本篇博客两个星期前已经存为草稿,鉴于发生一些糟糕的事情,今天才基本完成.本人6月份应届毕业生一枚,毕业后当天来到帝都,之后也非常顺利,面试了俩家公司都成功了.一家做C++方面电商ERP,一家做w ...

  4. 你需要管理员权限才能删除文件夹及服务器C盘不及批处理

    Windows 7系统,管理员权限设置方法 一.选择文件夹或文件所有者 我们用鼠标右键点击要操作的文件或文件夹 - 属性: 在出现的文件夹属性窗口,我们用鼠标左键点击:安全: 我们用鼠标左键点击:高级 ...

  5. 《TCP/IP详解卷1:协议》第19章 TCP的交互数据流-读书笔记

    章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...

  6. 第二章:javascript: 数组

    数组是编程世界里最常见的数据结构.任何一种编程语言都包含数组,只是形式稍微有差异.数组是编程语言中的内建类型,通常效率都很高.可以满足不同需求的数据存储,本章将探索javascript中的数组工作原理 ...

  7. AngularJS - 服务简介

    服务是AngularJS中非常重要的一个概念,虽然我们有了控制器,但考虑到其生命实在脆弱,我们需要用到服务. 起初用service时,我便把service和factory()理所当然地关联起来了. 确 ...

  8. MongoDB学习与BUG解答

    简单介绍: MongoDb也是NoSQL中的一种,并且是应用比较火的一门解决高效处理数据的技术. 网上说它是介于关系数据库 和非关系数据库之间的产品,它是非关系数据库中最丰富的,最像关系数据的. Q: ...

  9. overlay-2

    <script src="/jquery.js"></script><script type="text/javascript"& ...

  10. 【ZOJ 1221】Risk

    题 题意 给你20个城市的相邻关系,求给定任意两个城市的最短距离 分析 求任意两个城市最短距离,就是用floyd算法,我脑残忘记了k是写在最外层的. 代码 #include<stdio.h> ...