Pagini recente » Cod sursa (job #3187844) | Autentificare | Cod sursa (job #2844990) | Cod sursa (job #2258082) | Cod sursa (job #114956)
Cod sursa(job #114956)
program litere;
var i,n, sch: longint;
l : array [1..10000] of char;
fin,fout : text;
procedure bubblesort;
var s : boolean;
aux : char;
begin
sch :=0;
repeat
s := false;
for i := 1 to n-1 do
if l[i]>l[i+1] then
begin
sch := sch+1;
s := true;
aux := l[i];
l[i]:=l[i+1];
l[i+1]:=aux;
end;
until s = false;
end;
Begin
assign(fin,'litere.in'); reset(fin);
assign(fout,'litere.out'); rewrite(fout);
readln(fin,n);
for i := 1 to n do
read(fin,l[i]);
BUBBLESORT;
writeln(fout,sch);
close(fout);
close(fin);
End.