unit Un123213213213it1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
var
A, B, C: Double;
x, y: Integer;
CodeA, CodeB, CodeC: Integer;
LeftPart: Double;
Found: Boolean;
begin
ListBox1.Clear;
Found := False;
Val(Edit2.Text, A, CodeA);
Val(Edit3.Text, B, CodeB);
Val(Edit4.Text, C, CodeC);
if (CodeA <> 0) or (CodeB <> 0) or (CodeC <> 0) then
begin
ShowMessage('Oshibka A B ili C');
Exit;
end;
if (A = 0) and (B = 0) then
begin
ShowMessage('Parametri A i B ne mogut bit 0');
Exit;
end;
for x := -20 to 20 do
for y := -20 to 20 do
begin
LeftPart := A * x * x + B * y * y;
if Abs(LeftPart - C) < 1E-9 then
begin
ListBox1.Items.Add(
Format('x = %d, y = %d (%.1f*%d^2 + %.1f*%d^2 = %.1f)',
[x, y, A, x, B, y, C]));
Found := True;
end;
end;
if not Found then
ListBox1.Items.Add('Resheniy v diapazone -20..20 ne najdeno');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ListBox1.Sorted := True;
end;
end.