Nech sa páči, malo by to fungovať správne

. Je to zapuzdrené v triede TInterval kôli jednoduchému ovládaniu. To si ale samozrejme uprav podľa tvojich potrieb. Celá "veda" je vo funkcii
Is1In2:
Kód:
unit Unit1;
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs;
interface
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
INTERVAL = record
_od, _do: byte;
end;
TInterval = class
int_1, int_2: INTERVAL;
public
function Is1In2: boolean;
constructor Create(i1, i2: INTERVAL);
destructor Destroy; override;
end;
var
Form1: TForm1;
prvy_interval, druhy_interval: INTERVAL;
moje_intervaly: TInterval;
implementation
{ TForm1 }
constructor TInterval.Create(i1, i2: INTERVAL);
begin
if (int_1._od = 0) then int_1._od:= 24; // oprava v pripade chybneho zadania}
if (int_1._do = 0) then int_1._do:= 24;
if (int_2._od = 0) then int_2._od:= 24;
if (int_2._do = 0) then int_2._do:= 24;
int_1:= i1;
int_2:= i2;
end;
destructor TInterval.Destroy;
begin
inherited;
end;
function TInterval.Is1In2: boolean;
begin
result:= false;
if not( (int_1._od >= int_2._od) or (int_1._od <= int_2._do) ) then exit;
if not( (int_1._do >= int_2._od) or (int_1._do <= int_2._do) ) then exit;
result:= true;
end;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
prvy_interval._od:= 22; prvy_interval._do:= 1;
druhy_interval._od:= 22; druhy_interval._do:= 2;
moje_intervaly:= TInterval.Create(prvy_interval, druhy_interval);
if moje_intervaly.Is1In2 then
ShowMessage('ok');
end;
end.