урок на делфи 34 - Текст в азбуку Морзе


задание на delphi. морзянка на делфи


unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
s,d:string;
begin
s:=LowerCase(Memo1.Text);
d:='';
for I := 1 to Length(s) do
begin
if s[i]='а' then
d:=d+'.-';
if s[i]='б' then
d:=d+'-...';
if s[i]='в' then
d:=d+'.--';
if s[i]='г' then
d:=d+'--.';
if s[i]='д' then
d:=d+'-..';
if s[i]='е' then
d:=d+'.';
if s[i]='ж' then
d:=d+'...-';
if s[i]='з' then
d:=d+'--..';
if s[i]='и' then
d:=d+'..';
if s[i]='й' then
d:=d+'.---';
if s[i]='к' then
d:=d+'-.-';
if s[i]='л' then
d:=d+'.-..';
if s[i]='м' then
d:=d+'--';
if s[i]='н' then
d:=d+'-.';
if s[i]='о' then
d:=d+'---';
if s[i]='п' then
d:=d+'.--.';
if s[i]='р' then
d:=d+'.-.';
if s[i]='с' then
d:=d+'...';
if s[i]='т' then
d:=d+'-';
if s[i]='у' then
d:=d+'..-';
if s[i]='ф' then
d:=d+'..-.';
if s[i]='х' then
d:=d+'....';
if s[i]='ц' then
d:=d+'-.-.';
if s[i]='ч' then
d:=d+'---.';
if s[i]='ш' then
d:=d+'----';
if s[i]='щ' then
d:=d+'--.-';
if s[i]='ъ' then
d:=d+'.--.-.';
if s[i]='ы' then
d:=d+'-.--';
if s[i]='ь' then
d:=d+'-..-';
if s[i]='э' then
d:=d+'..-..';
if s[i]='ю' then
d:=d+'..--';
if s[i]='я' then
d:=d+'.-.-';
if s[i]=' ' then
d:=d+' ';
end;
Memo2.Lines.Add(d);
end;
end.



Скачать