fork download
  1. uses Math;
  2.  
  3. const LOW_RANGE=32;
  4. const HIGH_RANGE=127;
  5. var Counters:array[LOW_RANGE-1..HIGH_RANGE+1] of Cardinal;
  6. var Line:String;
  7. var I:Integer;
  8. begin
  9. Write('Type the string: ');
  10. ReadLn(Line);
  11. for I:=Low(Counters) to High(Counters) do Counters[I]:=0;
  12. for I:=1 to Length(Line) do Inc(Counters[Min(High(Counters),Max(Low(Counters),Ord(Line[I])))]);
  13. WriteLn(Line);
  14. for I:=LOW_RANGE to HIGH_RANGE do if Counters[I]>0 then WriteLn('''',Chr(I),'''',Counters[I]:4);
  15. end.
Success #stdin #stdout 0s 444KB
stdin
Ala ma kota
stdout
Type the string: Ala ma kota
' '   2
'A'   1
'a'   3
'k'   1
'l'   1
'm'   1
'o'   1
't'   1