Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2008.06.22;
Скачать: CL | DM;

Вниз

radiogroup   Найти похожие ветки 

 
rena ©   (2008-05-27 23:32) [0]

unit Unit6;

interface

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

type

 TForm6 = class(TForm)
   Label3: TLabel;
   Button1: TButton;
   Label1: TLabel;
   Label2: TLabel;
   StringGrid1: TStringGrid;
   StringGrid2: TStringGrid;
   RadioGroup1: TRadioGroup;
   RadioGroup2: TRadioGroup;
   RadioGroup3: TRadioGroup;
   RadioGroup4: TRadioGroup;
   procedure FormClose(Sender: TObject; var Action: TCloseAction);
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

 T_Key=integer;
 T_item=integer;
 Sortmas=record
    key:T_key;
    item:T_item;
 end;
 //Основной класс
 TSortClass=class
   a:array of Sortmas;
   RadioGroup3: TRadioGroup;
   StringGrid1: TStringGrid;
 Constructor Create(ar:array of longint);
 procedure otobrajenie1;
 procedure otobrajenie2;
 procedure otobrajenie3;
 procedure zapolnenie;
 procedure Sortirovka;//virtual;abstract;
   end;

 //Классы-наследники
 TSimple=class(TSortClass)
 StringGrid2: TStringGrid;
 constructor Create(ar:array of Longint);
 procedure SimpleSort;
 procedure SimpleSort2;
   end;

 TQuickly=class(TSortClass)
 StringGrid2: TStringGrid;
 constructor Create(ar:array of Longint);
 procedure QSort(var a: array of Sortmas; iLo, iHi: Integer);
 procedure QuicklySort;
 procedure QuicklySort2;
   end;
   
 TSliyanie=class(TSortClass)
 StringGrid2: TStringGrid;
 constructor Create(x:array of Longint);
//процедура разбивки на куски с рекурсией и вызов сортировки
//передаем сам массив,индеск первого и последнего элемента
 procedure Sort(x:array of sortmas;first,last:integer);
 //Расположение по возрастанию
 procedure SliyanieSort2;
 //Расположение по убыванию
 procedure SliyanieSort;
 //Cама сортировка
 procedure SortS(var x:array of sortmas; first,middle,last:integer);
 end;

var
 Form6: TForm6;
 i:integer;
 k:TSortClass;
 l:TSimple;
 q:TQuickly;
 s:TSliyanie;
 ar:array of Longint;

implementation

uses MainUnit1,Unit3,Unit4,Unit5;
{$R *.dfm}

procedure TForm6.Button1Click(Sender: TObject);
begin
if Radiogroup1.ItemIndex=0//Cортировка выбором
then begin//Выделение памяти
 k:=TSimple.Create(ar);
 k.zapolnenie;
 if Radiogroup2.ItemIndex=0//Возрастание
 then l.SimpleSort
 else if Radiogroup2.ItemIndex=1//Убывание
 then l.SimpleSort2;
     end
else if Radiogroup1.ItemIndex=1//Быстрая сортировка
 then begin//Выделение памяти
 k:=TQuickly.Create(ar);
 k.zapolnenie;
 if Radiogroup2.ItemIndex=0//Возрастание
 then q.QuicklySort
 else if Radiogroup2.ItemIndex=1//Убывание
 then q.QuicklySort2
      end
else if Radiogroup1.ItemIndex=2//Cортировка слиянием
 then begin//Выделение памяти
 k:=TSliyanie.Create(ar);
 k.zapolnenie;
 if Radiogroup2.ItemIndex=0//Возрастание
 then
 s.SliyanieSort
 else if Radiogroup2.ItemIndex=1//Убывание
 then s.SliyanieSort2
      end;

if Radiogroup4.ItemIndex=0 then k.otobrajenie1
else if Radiogroup4.ItemIndex=1 then k.otobrajenie2
else if Radiogroup4.ItemIndex=2 then k.otobrajenie3;
end;

procedure TForm6.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;

constructor TSliyanie.Create(x:array of Longint);
begin
//Сортирока слияниями(метод фон Неймана)
//Выделение памяти
inherited Create(ar);
end;

...

{TSimple }

//Cортировка вставками
constructor TSimple.Create(ar:array of Longint);
begin
//Создание массива
inherited Create(ar);
end;

procedure TSimple.SimpleSort;
var i,j,k:integer; x:Sortmas;
begin //массив a
StringGrid2.ColCount:=r;
for i:=0 to r-1 do
 begin
k:=i;
x:=a[i];
for j:=i+1 to r do
begin
 if a[j].key <x.key then
begin k:=j; x:=a[j];
a[k]:=a[i]; a[i]:=x;
end;
end;
StringGrid2.Cells[i,0]:=IntToStr(a[i].key);
end;
end;

procedure TSimple.SimpleSort2;
var i,j,k:integer; x:Sortmas;
begin //массив a
StringGrid2.ColCount:=r;
for i:=0 to r-1 do
 begin
k:=i;
x:=a[i];
for j:=i+1 to r do
begin
 if a[j].key<x.key then
begin k:=j; x:=a[j];
a[k]:=a[i]; a[i]:=x;
end;
end;
end;
j:=0;
for i:=r-1 downto 0 do
begin
StringGrid2.Cells[i,0]:=IntToStr(a[j].key);
j:=j+1;
end;
end;

{ TSortClass }

constructor TSortClass.Create(ar:array of longint);
begin
//Выделение памяти
SetLength(a,r);
end;

procedure TSortClass.otobrajenie1;
//Отображение звездочками
var NewForm: TForm3;
begin
NewForm:=TForm3.Create(Application);
end;

procedure TSortClass.otobrajenie2;
//Отображение линиями
var NewForm: TForm4;
begin
NewForm:=TForm4.Create(Application);
end;

procedure TSortClass.otobrajenie3;
//Отображение мозаикой
var NewForm: TForm5;
begin
NewForm:=TForm5.Create(Application);
end;

procedure TSortClass.Sortirovka;
begin
//Cортировка
//i:=i+1;
end;

procedure TSortClass.zapolnenie;
begin
//Заполнение массива
//Setlength(ar,r);
if Radiogroup3.ItemIndex=0 then
for i:=0 to r-1 do
a[i].key:=randmas[i]
else if Radiogroup3.ItemIndex=1 then
for i:=0 to r-1 do
a[i].key:=masgen[i]
else if Radiogroup3.ItemIndex=2 then
for i:=0 to r-1 do
a[i].key:=raspr[i];
StringGrid1.ColCount:=r;
//SetLength(a,r);
for i:=0 to r-1 do
StringGrid1.Cells[i,0]:=IntToStr(a[i].key);
end;

{ TQuickly }

...

при выполнении процедуры zapolnenie происходит ошибка при проверке условия if Radiogroup3.ItemIndex=0 then ... причем нужная радиокнопка помечена. Может, не там объявлен компонент Radiogroup3? При объявлении в описании класса формы компонент вообще определялся как undeclared , прописала в классе TSortClass..


 
engine ©   (2008-05-27 23:39) [1]

почитай Конопку Рэя.



Страницы: 1 вся ветка

Текущий архив: 2008.06.22;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.019 c
2-1211869691
TRSteep
2008-05-27 10:28
2008.06.22
const array


15-1210236649
JanMihail
2008-05-08 12:50
2008.06.22
Схема документа MS Word


2-1211961384
Кирей
2008-05-28 11:56
2008.06.22
Не работает простой запрос


15-1210342314
NetZorro
2008-05-09 18:11
2008.06.22
про Combobox ?


2-1211853105
Slevin
2008-05-27 05:51
2008.06.22
Clipboard