Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 19.11.2020, 21:20
KusokKysochek KusokKysochek вне форума
Прохожий
 
Регистрация: 19.11.2020
Сообщения: 1
Версия Delphi: Delphi 7
Репутация: 10
Печаль Программа шифровки-дешифровки текста

Здравствуйте, уважаемые знатоки. В чем я не прав? Программа шифровки-дешифровки текста, выбор метода реализовал через RadioGroup. Ошибок нет, но ничего не работает. Помогите, пожалуйста. Delphi 7.
Код:
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;
 
type
  TForm1 = class(TForm)
    mmo1: TMemo;
    mmo2: TMemo;
    btn1: TButton;
    btn2: TButton;
    lbl1: TLabel;
    lbl2: TLabel;
    edt1: TEdit;
    lbl3: TLabel;
    rg1: TRadioGroup;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
 
const alfa:array[0..65] of char = ('а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я','А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я');
var
  Form1: TForm1;
  a:array[0..65] of char;
  i, j, k: integer;
  s, s2, stroki, Last:string;
  c:char;
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
begin
  if rg1.ItemIndex=0
   then begin
  For i:=0 to 65 do
    begin
      a[i]:= alfa[(i+1) mod 66];
    end;
    // шифр
      k := StrToInt(edt1.Text);
      s := mmo1.Lines.Text;
      for i := 1 to length(s) do
        for j := 0 to 65 do
        if s[i] = a[j] then s2 := s2+a[(66+(j+k)) mod 66];
      mmo2.Lines.Text := s2;
      s2 := '';
      end;
 
   if rg1.ItemIndex=1
   then begin
 i := 1;
 if Length(mmo1.Text) mod 2 = 0
  then begin
        stroki := mmo1.Text;
        Last := '';
       end
  else begin
        stroki := Copy(mmo1.Text, 1, Length(mmo1.Text) - 1);
        Last := Copy(mmo1.Text, Length(mmo1.Text), 1);
       end;
 while i <= Length(stroki) do
  begin
   c := stroki[i];
   stroki[i] := stroki[i + 1];
   stroki[i + 1] := c;
   i := i + 2;
  end;
 mmo2.Text := stroki + Last;
end;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
  if rg1.ItemIndex=0
   then begin
      s2:='';
      k := StrToInt(edt1.Text);
      s := mmo1.Lines.Text;
      for i := 1 to length(s) do
        for j := 0 to 65 do
        if s[i] = a[j] then s2 := s2+a[(66+(j-k)) mod 66];
      mmo2.Lines.Text := s2;
      s2 := '';
if rg1.ItemIndex=1
   then begin
if rg1.ItemIndex=1
   then begin
 i := 1;
 if Length(mmo2.Text) mod 2 = 0
  then begin
        stroki := mmo2.Text;
        Last := '';
       end
  else begin
        stroki := Copy(mmo2.Text, 1, Length(mmo1.Text) + 1);
        Last := Copy(mmo2.Text, Length(mmo1.Text), 1);
       end;
 while i <= Length(stroki) do
  begin
   c := stroki[i];
   stroki[i] := stroki[i - 1];
   stroki[i - 1] := c;
   i := i - 2;
  end;
 mmo1.Text := stroki + Last;
end;
end;
end;
end;
end.
Вложения
Тип файла: rar Шифрование.rar (3.5 Кбайт, 0 просмотров)
Ответить с цитированием
 


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 18:58.


 

Сайт

Форум

FAQ

RSS лента

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2023

ВКонтакте   Facebook   Twitter