首页 > 代码库 > 【USACO】name that number

【USACO】name that number

{ID: anniel11PROG: namenumLANG: PASCAL}Program namenum;var  i,n,l:integer;  s,s2:string;  dicl:array[1..12] of integer;  dic:array[1..12,1..2000] of integer;function transs(c:char):string;var  trans:integer;begin  case c of  A,B,C:trans:=2;  J,K,L:trans:=5;  T,U,V:trans:=8;  D,E,F:trans:=3;  M,N,O:trans:=6;  W,X,Y:trans:=9;  G,H,I:trans:=4;  P,R,S:trans:=7;  end;  str(trans,transs);end;begin  assign(input,dict.txt);  while not eof do  begin    readln(s);    inc(dicl[length(s)]);    t1:=0;    s2:=‘‘;    for i:=1 to length(s) do s2:=s2+transs(s[i]);    val(s2,dic[length(s),dicl[length(s)]]);  end;  close(input);  assign(input,namenum.in);  assign(output,namebum.out);  reset(input);rewrite(output);  readln(n);  str(n,s);  l:=length(s);  close(input);close(output);end.

 

【USACO】name that number