POJ 1002(字符串处理)

这题就是字符串处理


Program P1002;
Type
   phone=record
         num,s:longint;
         end;
var
   n,i,j,p:Longint;
   b:boolean;
   s:ansistring;
   a:array[0..9999999] of longint;
// f:array[1..100000] of phone;
   ch:array['A'..'Z'] of longint=(2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,-1,7,7,8,8,8,9,9,9,-1);
function isdight(c:char):longint;
var
   i,j,p:longint;
begin
   p:=ord(c);
   if (48<=p) and (p<58) then exit(p-48);
   if (65<=p) and (p<=90) then
   begin
      if ch[c]<>-1 then exit(ch[c]);
   end;
   exit(-1);

end;
function hash:longint;
var
   i,j,p:longint;
begin
   j:=0;
   hash:=0;
   for i:=1 to length(s) do
   begin
      if s[i]='-' then continue;
      p:=isdight(s[i]);
      if (p=-1) or ((p<>-1) and (j=7)) then exit(-1);
      hash:=hash*10+p;
      inc(j);
   end;
   if j<>7 then exit(-1);
end;
procedure pri(p:longint);
var
   i,j:longint;
begin
   b:=true;
   i:=p div 10000;
   j:=p mod 10000;
   if i<100 then write('0');
   if i<10 then write('0');
   write(i,'-');
   if j<1000 then write('0');
   if j<100 then write('0');
   if j<10 then write('0');
   writeln(j,' ',a[p]);
end;
Begin
   b:=false;
   readln(n);
   fillchar(a,sizeof(a),0);
   for i:=1 to n do
   begin
      readln(s);
      p:=hash;
      if p=-1 then continue
      else inc(a[p]);
   end;
   for i:=0 to 9999999 do
      if a[i]>1 then pri(i);
   if not(b) then writeln('No duplicates.');


End.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值