[POJ1035 Spell checker]
2011-11-02 09:38
369 查看
[题目来源]:Northeastern Europe 1998
[关键字]:字符串处理
[题目大意]:给出一个字典,然后查询一些字符是否能字典中的匹配。匹配是指:1、相等;2、少一个其余相等;3、多一个其余相等。
//=====================================================================================================
[分析]:只要根据要求一一测试,将正在查的单词与字典中的每一个比对,如果长度相等则判断是否一样,如果多一个则枚举删掉该词的一位再判断是否一样,如果少一个则枚举删掉字典中那个词的一位再判断。
[代码]:
View Code
[关键字]:字符串处理
[题目大意]:给出一个字典,然后查询一些字符是否能字典中的匹配。匹配是指:1、相等;2、少一个其余相等;3、多一个其余相等。
//=====================================================================================================
[分析]:只要根据要求一一测试,将正在查的单词与字典中的每一个比对,如果长度相等则判断是否一样,如果多一个则枚举删掉该词的一位再判断是否一样,如果少一个则枚举删掉字典中那个词的一位再判断。
[代码]:
View Code
{ PROB:POJ1035 DATE:2011\10\16 } type rec = record s: string; num: longint; dat: array[0..10000] of string; end; var tot: longint; w: array[0..10010] of string; ans: array[0..60] of rec; function ind(s: string):boolean; var i: longint; begin for i := 1 to tot do if s = w[i] then exit(true); exit(false); end; procedure instead(s: string; t: longint); var i, j, dif: longint; s2: string; begin for i := 1 to tot do begin if length(s)-length(w[i]) = 1 then for j := 1 to length(s) do begin s2 := s; delete(s2,j,1); if s2 = w[i] then begin write('',w[i]); break; end; end; if length(s) = length(w[i]) then begin dif := 0; for j := 1 to length(s) do begin if s[j] <> w[i][j] then inc(dif); if dif = 2 then break; end; if dif = 1 then write('',w[i]); end; if length(s)-length(w[i]) = -1 then for j := 1 to length(w[i]) do begin s2 := w[i]; delete(s2,j,1); if s2 = s then begin write('',w[i]); break; end; end; end; end; procedure init; var s: string; i, j, t: longint; temp: rec; begin readln(s); while s[1] <> '#' do begin inc(tot); w[tot] := s; readln(s); end; //======================================================================== readln(s); t := 0; while s[1] <> '#' do begin if ind(s) then begin writeln(s,' is correct'); readln(s); continue; end; write(s,':'); instead(s,t); writeln; readln(s); end; //========================================================================= end; begin assign(input,'1.in');reset(input); assign(output,'1.out');rewrite(output); init; close(input); close(output); end.
相关文章推荐
- 字符串 模拟 Spell checker (poj 1035)
- POJ1035 Spell-checker(哈希,串处理)
- POJ 1035 Spell checker 字符串暴力
- POJ1035-Spell checker(java版)
- poj 1035 Spell checker 字符串,暴力
- 字符串 模拟 Spell checker (poj 1035)
- POJ 1035 Spell checker【字符串暴力处理】
- POJ训练计划1035_Spell checker(串处理/暴力)
- POJ1035 Spell-checker(哈希,串处理)
- poj 1035 Spell checker ( 字符串处理 )
- poj 1035 Spell checker ( 字符串处理 )
- poj 1035 Spell checker(字符串处理)
- poj 1035--Spell checker
- POJ 1035 Spell checker (串)
- POJ 1035-Spell checker(字符串)
- POJ 1035 Spell checker (字符串)
- poj 1035 Spell checker
- poj 1035 Spell checker【字符串】
- [ACM] POJ 1035 Spell checker (单词查找,删除替换增加任何一个字母)
- POJ - 1035 Spell checker解题报告