POJ1002 487-3249

来源:互联网 发布:淘宝盗图被投诉怎么办 编辑:程序博客网 时间:2024/06/14 09:54

本题是一个明显的字符串处理问题,主要包含转换以及判重,只需注意细节即可,没有任何难度。

Program POJ1002;//by_poet_shyConst      d:array['A'..'Z']of integer=(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);      maxn=9999999;Var      i,j,k              :longint;      s                  :string;      a                  :array[0..maxn]of longint;Procedure Main;var bo:boolean;begin  readln(k);  for i:=1 to k do    begin  readln(s);  j:=1;  while j<=length(s) do    begin  if s[j]='-' then    begin  delete(s,j,1);  continue;end;  if ord(s[j])>=65 thens[j]:=chr(d[s[j]]+48);  inc(j);end;  val(s,j);  inc(a[j]);end;  bo:=false;  for i:=0 to maxn do    if a[i]>1 then  begin    str(i,s);while length(s)<7 do  insert('0',s,1);write(copy(s,1,3));write('-');write(copy(s,4,4),' ');writeln(a[i]);                bo:=true;  end;  if not bo then writeln('No duplicates.');end;//===========================================================BEGIN  main;END.

原创粉丝点击