POJ 1002(字符串处理)
2012-08-07 17:13
344 查看
这题就是字符串处理
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.
相关文章推荐
- poj 1002 方便记忆的电话号码 字符串处理+排序
- POJ 1002 487-3279 字符串处理
- POJ 1002(不用排序的方法)(简单的字符串处理程序)
- POJ 1002 电话号码字符串处理
- poj 1002 电话号码\字符串处理
- POJ 1002 电话号码字符串处理
- POJ 1002 487-3279 水题字符串
- POJ1002 487-3279 字符串 C语言
- poj 1002 字符串
- poj 2408 Anagram Groups 字符串处理题
- 字符串处理,Poj(2121)
- POJ 2271 HTML (字符串处理)
- C++——字符串例题——487-3279(POJ1002)
- 1002.写出这个数(字符串处理)
- poj 1580 String Matching 【字符串处理】
- UVa 112|POJ 1145|Tree Summing|字符串处理|树的遍历
- hdu 1063 poj 1001 字符串处理 数学相关
- POJ 3267-The Cow Lexicon(DP处理字符串)
- POJ 2503 二分 还有一些基本字符串的处理
- poj 2141 Message Decowding 带空格字符串的处理