⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac1056.pas

📁 同济大学 Online在线题库 AC源代码合集 程序设计竞赛必看资料
💻 PAS
字号:
program tju1056;
const
  num:array['A'..'Z']of byte=(2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9);
  maxwords=100;
type
  shortstr=string[10];
var
  w,x:array[1..maxwords]of shortstr;
  n,i,j:byte;
  s:shortstr;
function dif1(a,b:shortstr):boolean;
  var
    i,c:byte;
  begin
    c:=0;
    for i:=1 to length(a) do begin
      if a[i]<>b[i] then inc(c);
      if c>1 then break;
    end;
    dif1:=c=1;
  end;
begin
  repeat
    readln(n);
    for i:=1 to n do
      readln(w[i]);
    for i:=1 to n-1 do
      for j:=i+1 to n do
        if w[i]>w[j] then begin
          s:=w[i];w[i]:=w[j];w[j]:=s;
        end;
    for i:=1 to n do begin
      x[i]:='';
      for j:=1 to length(w[i]) do
        x[i]:=x[i]+chr(48+num[w[i,j]]);
    end;

    readln(s);j:=length(s);
    for i:=1 to n do
      if x[i]=s then writeln(w[i]);
    for i:=1 to n do
      if (length(x[i])>j) and (copy(x[i],1,j)=s) then writeln(w[i]);
    for i:=1 to n do
      if (length(x[i])=j) and dif1(x[i],s) then writeln(w[i]);
    for i:=1 to n do
      if (length(x[i])>j) and dif1(copy(x[i],1,j),s) then writeln(w[i]);
  until seekeof;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -