您的位置:首页 > 其它

UVa OJ 10008-What's Cryptanalysis?

2011-01-31 00:32 471 查看
简单统计,水题:

{
Author:wzx961008
Problem:UVa 10008-What's Cryptanalysis?
Verdict:Accepted
Language:PASCAL
Run Time:0.016s
Submission Date:2011-01-30 16:26:08
}
type letter=record
c:char;
num:longint;
end;
var i,j,n,top:longint;
t:letter;
c,ii:char;
a:array[1..26]of letter;
f:array['A'..'Z']of longint;
begin
readln(n);
for i:=1 to n do begin
while not eoln do begin
read(c);
if (c>='A')and(c<='z') then inc(f[upcase(c)]);
end;
readln;
end;
for ii:='A' to 'Z' do begin
a[ord(ii)-64].c:=ii;
a[ord(ii)-64].num:=f[ii];
end;
for i:=1 to 25 do
for j:=i+1 to 26 do
if a[i].num<a[j].num then begin
t:=a[i]; a[i]:=a[j]; a[j]:=t;
end else if a[i].num=a[j].num then if a[i].c>a[j].c then begin
t:=a[i]; a[i]:=a[j]; a[j]:=t;
end;
for i:=1 to 26 do
if a[i].num<>0 then writeln(a[i].c,' ',a[i].num);
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: