Created
July 17, 2013 16:20
-
-
Save residentkrm/6022104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program project1; | |
{$mode objfpc}{$H+} | |
uses | |
{$IFDEF UNIX}{$IFDEF UseCThreads} | |
cthreads, | |
{$ENDIF}{$ENDIF} | |
Classes, Crt; | |
{$R *.res} | |
type | |
data = record | |
letter: char; | |
count: integer; | |
end; | |
Var | |
a: array [1..1000] of data; | |
temp: data; | |
c: char; | |
i,j,n: integer; | |
begin | |
ClrScr; | |
n:=0; | |
Read(c); | |
While c<>'.' do | |
begin | |
Inc(n); | |
a[n].letter:=c; | |
a[n].count:=1; | |
Read(c); | |
end; | |
Writeln; | |
For i:=1 to n do | |
begin | |
For j:=i+1 to n do | |
if a[i].letter=a[j].letter | |
then | |
Inc(a[i].count); | |
end; | |
For i:=1 to n-1 do | |
For j:=1 to n-i do | |
If a[j].letter>a[j+1].letter | |
then | |
begin | |
temp:=a[j]; | |
a[j]:=a[j+1]; | |
a[j+1]:=temp; | |
end; | |
For i:=1 to n-1 do | |
For j:=1 to n-i do | |
If a[j].count<a[j+1].count | |
then | |
begin | |
temp:=a[j]; | |
a[j]:=a[j+1]; | |
a[j+1]:=temp; | |
end; | |
For i:=1 to n do | |
begin | |
For j:=i+1 to n do | |
if a[i].letter=a[j].letter | |
then | |
a[j].count:=0; | |
If a[i].count<>0 | |
then | |
Write(a[i].letter); | |
end; | |
ReadLn; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment