AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Buchstabenhäufigkeit

Ein Thema von Lisa.99 · begonnen am 13. Feb 2017 · letzter Beitrag vom 6. Mär 2017
 
Lisa.99

Registriert seit: 13. Feb 2017
21 Beiträge
 
#17

AW: Buchstabenhäufigkeit

  Alt 20. Feb 2017, 07:21
Habe nur das um die Buchstabenanzahl anzuzeigen:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var text : string;
    i, anzahl, Index, Ordnungszahl : integer;
    Buchstabe, key : char;
begin
 if not (key in [#65..#90, #97..#122, #8]) then
  key := #0;

 StringGrid1.Cells[0,0]:= 'Buchstabe';
 StringGrid1.Cells[1,0]:= 'Häufigkeit';
 StringGrid1.Cells[2,0]:= 'Prozent';

 for i := 0 to 26 do
 begin
   StringGrid1.Cells[0,i+1]:= char (i+65);
 end;
 text:= Edit1.Text;
 text:=stringreplace(text,' ','',[rfReplaceAll]);
 for n1 := 1 to length (text) do
    begin
    Buchstabe := text[n1];
    Buchstabe := Upcase (Buchstabe);
    Ordnungszahl:= Ord(Buchstabe);
    Index:= Ordnungszahl-64;
    if Index in [1..26] then
      begin
      anzahl := StrToIntDef(StringGrid1.Cells[1,Index],0);
      anzahl := anzahl + 1;
      StringGrid1.Cells[1,Index] := inttostr(anzahl);
      end;
    end;
   Edit2.Text:= inttostr(n1-1);
end;

Geändert von MrSpock (20. Feb 2017 um 07:43 Uhr) Grund: Delphi - Tags hinzugefügt.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:00 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz