博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 1035 Spell checker
阅读量:4612 次
发布时间:2019-06-09

本文共 2976 字,大约阅读时间需要 9 分钟。

Spell checker
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 16225   Accepted: 5938

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

iishashavebemymorecontestmetooifaward#meawaremcontesthavooorifimre#

Sample Output

me is correctaware: awardm: i my mecontest is correcthav: has haveoo: tooor:i is correctfi: imre: more me 字符串处理问题 先把字典和每个单词的长度存储下来 之后对每一个待检测的单词,首先扫描一遍整个字典,看有没有一样的,如果有就输出correct,如果没有,再扫描一遍整个字典,对于字典中与待检测单词长度小于1的单词重点检查,看能否经过题目中给定的转换变修改回去即可
1 #include
2 #include
3 4 using namespace std; 5 6 typedef struct 7 { 8 char s[16]; 9 int len;10 } DIC;11 12 DIC word[10000];13 14 void Equal(int i,char *s)15 {16 int pos=-1;17 18 for(int j=0;j
>temp&&temp[0]!='#')62 {63 strcpy(word[dic_num].s,temp);64 word[dic_num++].len=strlen(temp);65 }66 67 while(cin>>temp&&temp[0]!='#')68 {69 bool flag=true;70 int len=strlen(temp);71 for(int i=0;i
[C++]

 

转载于:https://www.cnblogs.com/lzj-0218/archive/2013/05/30/3108840.html

你可能感兴趣的文章
POJ 1833 排列
查看>>
Codeforces Round #459 (Div. 2) AB
查看>>
ubuntu下Gradle离线安装
查看>>
Linux入门-压缩、解压
查看>>
文件上传漏洞(绕过姿势)
查看>>
第三次作业
查看>>
代理模式(Proxy)
查看>>
个人作业——软件工程实践总结作业
查看>>
IOS上iframe的滚动条失效的解决办法。
查看>>
CodeForces660B【模拟—水】
查看>>
Codeforces 749C【模拟】
查看>>
centos7下pymysql安装
查看>>
使用java解析和制作二维码
查看>>
加油!!!
查看>>
在eclipse里卸载已安装的插件[例如Android Development Tools ADT]
查看>>
函数参数引用
查看>>
PCB接地设计宝典:ADI资深专家总结的良好接地指导原则
查看>>
使用wxPython WebView浏览器版本问题
查看>>
ArcGIS Online快速制图教程
查看>>
数组的一维下标换为指定的key值
查看>>