Section 1.2 Name That Number

来源:互联网 发布:java简单迷宫算法 编辑:程序博客网 时间:2024/05/05 17:23

此题主要考察文件操作 由于数据量小 所以可以顺序查找 至于字母与数字的对应 可以直接打表

{
ID: yaoyuan4
PROG: namenum
LANG: PASCAL
}
Program namenum;
const
  inf = 'namenum.in'; outf = 'namenum.out'; txt = 'dict.txt';
  a : array['A'..'Z'] of char =
('2', '2', '2', '3', '3', '3',
  '4', '4', '4', '5', '5', '5',
  '6', '6', '6', '7', '0', '7',
  '7', '8', '8', '8', '9', '9', '9', '0');
var
  t : text;
  s : string;
  ans : longint;
Procedure init;
  begin
   assign(input, inf); reset(input);
   readln(s);
   close(input);
  end;
Procedure work;
  var
   b, c : string;
   i : longint;
   flag : boolean;
  begin
   flag := true;
   assign(t, txt); reset(t);
   assign(output, outf); rewrite(output);
   repeat
    readln(t, b);
    for i := 1 to length(b) do
      c := c + a[b[i]];
    if c = s then
     begin
      flag := false;
      writeln(b);
     end;
    c := '';
   until eof(t);
   close(t);
   if flag then writeln('NONE');
   close(output);
  end;
begin
  init;
  work;
end.