Zastúpenie písmen (znakov) v danom reťazci

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Kategória: Zadania Pascal

Autor: Pheo
web: pascalsource.ic.cz

Program: Text_pocet.pas
Súbor exe: Text_pocet.exe

Zastúpenie písmen (znakov) v danom reťazci.
{ TEXT_POCET.PAS                                 Copyright (c) Pheo }
{ Zastúpenie písmen (znakov) v danom reazci.                       }
{                                                                   }
{ Datum:23.05.2000                             http://www.trsek.com }
 
program text_pocet;
uses crt;
type index='a'..'z';
var a:array[ index ] of integer;
    s:char;
    f:integer;
 
begin
     f:=f+1;
     if f=4 then f:=0;
     case f of
          0:textcolor(green);
          1:textcolor(red);
          2:textcolor(yellow);
          3:textcolor(blue);
     end;
     writeln('Zastupenie pismen (znakov) v danom retazci.');
     writeln('Zadaj text');
     for s:= 'a' to 'z' do a[s]:=0;
     while not eoln do
     begin
          read(s);
          if (s>='a')and(s<='z') then a[s]:=a[s]+1
     end;
 
     for s:='a' to 'z'  do
        write('pocet ':3,s,' je ',a[s],' ':4);
 
     writeln; readln;
end.