const n=23;
var
i,j,temp,v:integer;
a:array[1..n] of char;
b:array[0..9]of integer;
begin
for i:=1 to n do read (a[i]);
for i:=0 to 9 do b[i]:=0;
for i:=1 to n do
begin
val(a[i],v,j);
b[v]:=b[v]+1;
end;
for i:=1 to 9 do
for j:=0 to 9-i do
if b[j]>b[j+1] then
begin
temp:=b[j];
b[j]:=b[j+1];
b[j+1]:=temp;
end;
j:=0;
while b[j]=0 do j:=j+1;
for i:=j to 9 do write(b[i]:3);
end.
程序输入:22334455664567655555445 输出: 1 2 2 4 5 9
|