unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.Grids,
Vcl.StdCtrls,
Vcl.ExtCtrls;
type
TForm1 =
class(TForm)
Panel1: TPanel;
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
StringGrid1: TStringGrid;
Button2: TButton;
Label2: TLabel;
Edit2: TEdit;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var n1: integer;
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var text :
string;
i, anzahl,
Index, Ordnungszahl, result, b, ergebnis : 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;
procedure TForm1.Button2Click(Sender: TObject);
var n2, j1, i1, Bu, Er, A, B, C, D, E, F, G, H, I, J, K , L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, E1: integer;
begin
{for j1 := 1 to StringGrid1.RowCount do
begin
if strtoint(StringGrid1.Cells[1,n2]) >= 1 then
begin
Bu:= strToint(StringGrid1.Cells[1,n2]);
Er:= (Bu*100)/n1;
StringGrid1.Cells[2,n2]:= inttostr(Er);
end;
end;}
n1:= strtoint(Edit2.Text);
A:= strtoint(StringGrid1.Cells[1,1]);
if A >0
then
begin
E1:= (A*100)
div n1;
StringGrid1.Cells[2,1]:= inttostr(E1);
end
else
begin
E1:=0;
StringGrid1.Cells[2,1]:= inttostr(E1);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;
end.