linkedin facebook linkedin facebook nod32

Delphida simmetrik shifrlash va deshifrlashga misol

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2014-10-28

Delphida simmetrik shifrlash va deshifrlashga misol

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Buttons, ComCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Button1: TButton;
Button2: TButton;
Button4: TButton;
Panel2: TPanel;
StringGrid3: TStringGrid;
Button3: TButton;
StringGrid4: TStringGrid;
Edit4: TEdit;
Label4: TLabel;
StatusBar1: TStatusBar;
Timer1: TTimer;
Button5: TButton;
ColorDialog1: TColorDialog;
Button6: TButton;
Label5: TLabel;
Button7: TButton;
Button8: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
a,b,c,min:string;
i,j,h,k:integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Caption:='Berilgan matnni shifrlash';
Form1.Label5.Caption:='Shifrlash bo''limi';
Panel2.Visible:=False;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if (Edit1.Text='') or (Edit2.Text='') or (Edit3.Text='') then
begin
MessageDlg('Kalit so''z, ustun va satrni kiriting!',mtWarning,[mbYes],0);
StringGrid1.ColCount:=1;
StringGrid1.RowCount:=2;
StringGrid2.ColCount:=StringGrid1.ColCount;
StringGrid2.RowCount:=StringGrid1.RowCount;
StringGrid3.ColCount:=StringGrid1.ColCount;
StringGrid3.RowCount:=StringGrid1.RowCount;
StringGrid4.ColCount:=StringGrid3.ColCount;
StringGrid4.RowCount:=StringGrid3.RowCount;
StringGrid1.Cells[i,j]:='';
exit;
end
else
StringGrid1.ColCount:=StrToInt(Edit2.Text);
StringGrid1.RowCount:=1+StrToInt(Edit3.Text);
StringGrid2.ColCount:=StringGrid1.ColCount;
StringGrid2.RowCount:=StringGrid1.RowCount;
StringGrid3.ColCount:=StringGrid1.ColCount;
StringGrid3.RowCount:=StringGrid1.RowCount;
StringGrid4.ColCount:=StringGrid3.ColCount;
StringGrid4.RowCount:=StringGrid3.RowCount;
a:=Edit1.Text;
if Length(a)<>StrToInt(Edit2.Text) then begin
MessageDlg('Kalit so''z simvollari soni ustun soniga teng bo''lishi kerak!',mtWarning,[mbYes],0);
StringGrid1.ColCount:=1;
StringGrid1.RowCount:=2;
StringGrid2.ColCount:=StringGrid1.ColCount;
StringGrid2.RowCount:=StringGrid1.RowCount;
StringGrid3.ColCount:=StringGrid1.ColCount;
StringGrid3.RowCount:=StringGrid1.RowCount;
StringGrid4.ColCount:=StringGrid3.ColCount;
StringGrid4.RowCount:=StringGrid3.RowCount;
StringGrid1.Cells[i,j]:='';
exit;
end;
for i:=1 to Length(Edit1.Text) do
for j:=i to Length(Edit1.Text) do
if a[i]=a[j+1]then begin
MessageDlg('Kalit so''zda simvollar takrorlanmasin!',mtWarning,[mbYes],0);
StringGrid1.ColCount:=1;
StringGrid1.RowCount:=2;
StringGrid2.ColCount:=StringGrid1.ColCount;
StringGrid2.RowCount:=StringGrid1.RowCount;
StringGrid3.ColCount:=StringGrid1.ColCount;
StringGrid3.RowCount:=StringGrid1.RowCount;
StringGrid4.ColCount:=StringGrid3.ColCount;
StringGrid4.RowCount:=StringGrid3.RowCount;
StringGrid1.Cells[i,j]:='';
exit;
end;
for i:=1 to Length(Edit1.Text) do
begin
StringGrid1.Cells[i-1,0]:=a[i];
end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin

b:=a;
c:='';
repeat
min:=b[1];
for i:=2 to Length(b)do
if min<b[i] then
min:=min
else min:=b[i];
c:=c+min;
for i:=1 to Length(b) do
if b[i]=min then
delete(b,i,1);
until Length(b)=1;
c:=c+b;
for i:=1 to Length(c) do
For j:=1 to Length(a) do
if c[i]=a[j] then
for k:=0 to StrToInt(Edit3.Text) do
StringGrid2.Cells[i-1,k]:=StringGrid1.Cells[j-1,k];
for i:=0 to StrToInt(Edit2.Text) do
For j:=0 to StrToInt(Edit3.Text) do
StringGrid3.Cells[i,j]:=StringGrid2.Cells[i,j];

end;

procedure TForm1.Button4Click(Sender: TObject);
begin
Form1.Caption:='Berilgan matnni deshifrlash';
Form1.Label5.Caption:='Deshifrlash bo''limi';
Edit4.Text:=Edit1.text;
Panel1.Visible:=False;
Panel2.Visible:=True;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if Edit4.Text=Edit1.Text then else
begin
MessageDlg('Kalit so''z noto''g''ri kiritildi!',mtWarning,[mbYes],0);
StringGrid1.ColCount:=1;
StringGrid1.RowCount:=2;
StringGrid2.ColCount:=StringGrid1.ColCount;
StringGrid2.RowCount:=StringGrid1.RowCount;
StringGrid3.ColCount:=StringGrid1.ColCount;
StringGrid3.RowCount:=StringGrid1.RowCount;
StringGrid4.ColCount:=StringGrid3.ColCount;
StringGrid4.RowCount:=StringGrid3.RowCount;
StringGrid1.Cells[i,j]:='';
exit;
end;
For j:=1 to Length(Edit4.Text) do
for i:=0 to Length(Edit4.Text)-1 do
if Edit4.Text[j]=StringGrid3.Cells[i,0] then
for k:=0 to StrToInt(Edit3.Text) do
StringGrid4.Cells[j-1,k]:=StringGrid3.Cells[i,k]

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
StatusBar1.SimpleText:=' Joriy vaqt: '+TimeToStr(Time);
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
Form1.Caption:='Berilgan matnni shifrlash';
Form1.Label5.Caption:='Shifrlash bo''limi';
Panel2.Visible:=False;
Panel1.Visible:=True;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
if ColorDialog1.Execute then
Form1.Color:=ColorDialog1.Color;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose:=MessageDlg('Yakunlaysizmi?!',mtConfirmation,[mbYes,mbNo],0)=mrYes;
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
if CloseQuery then Application.Terminate;
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
StringGrid1.Cols[i].Clear;
StringGrid1.Rows[j].Clear;
end;

end.

2543 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений