unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
edt_name: TEdit;
Label1: TLabel;
Button1: TButton;
edt_start: TEdit;
lbl_name: TLabel;
lbl_letter: TLabel;
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
i,counter:integer;firstname:
array of string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function checkifstarting(a,b:
string):boolean;
var i:integer;
begin
result:=true;
for i:=1
to Length(a)
do
if a[i]<>b[i]
then result:=false;
end;
function checkifwithout(a,b:
string):boolean;
var i,k:integer;
begin
result:=true;
for i:=1
to Length(a)
do
for k:=1
to Length(b)
do
if a[i]=b[k]
then result:=false;
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
var l:integer;
begin
Label1.Caption:='
';
for l:=low(firstname)
to high(firstname)
do
if checkifstarting(edt_start.Text,firstname[l])=true
then Label1.Caption:=Label1.Caption + '
' + firstname[l]
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
var l:integer;
begin
label1.Caption:='
';
for l:=low(firstname)
to high(firstname)
do
if checkifwithout(edt_start.Text,firstname[l])=true
then Label1.Caption:=Label1.Caption + '
' + firstname[l]
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if counter <>0
then inc(i);
SetLength(firstname,i+1);
firstname[i]:=edt_name.Text;
edt_name.text:='
';
inc(counter);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
i:=0;
counter:=0;
end;
end.