Лшемді массивтің оң сандық элементтерін минимальды мәнге алмастыру және сұрыптау әдісі арқылы реттеңдер.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, Grids, StdCtrls;
Type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; StringGrid1: TStringGrid; Label2: TLabel;
procedure Button1Click(Sender: TObject) private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation{$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); const SIZE=10;
var a:array[1..SIZE] of integer;k:integer;i:integer;
changed:boolean; buf:integer;
begin
for i:=1 to SIZE do a[i] := StrToInt(StringGrid1.Cells[i-1, 0] );
label2.caption:=''; Changed:=FALSE;
for k:=1 to SIZE-1 do
if a[k] > a[k+1] then
begin
buf := a[k]; a[k] := a[k+1]; a[k+1] := buf; changed := TRUE;
end;
for i:=1 to SIZE do
Label2.caption:=label2.caption+' '+IntTostr(a[i]); Label2.caption:=label2.caption+#13;
Label2.caption:=label2.caption +#13+'Macив сурыпталды'; end ;
end.
Компоненттері нақты сандар болып табылатын f файл берілген. Табу керек: а) f файлының компоненттерінің қосындысын; б) файлдың соңғы компонентін.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm5 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
procedure TForm5.Button1Click(Sender: TObject);
var myfile:Textfile;
i:integer;
begin
AssignFile(myfile,'D:\1.txt');
rewrite(myFile);
for i:=1 to 5 do
writeln(myFile,i);
CloseFile(myFile);
end;
procedure TForm5.Button2Click(Sender: TObject);
begin
close
end;
end.
Графика
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private { Private declarations }
public { Public declarations }
end;
var Form1: TForm1;
implementation{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
With Form1.Canvas do // к каждой последующей строке добавлять
Begin
Pen.Width:=1; //установка полщины пера
Pen.Color:=clGreen; //установка цвета пера
Brush.Color:=clGreen; //установка цвета заливки
{Рисование елки}
PolyGon([Point(350,90),Point(330,90),Point(400,160),Point(380,160),
Point(470,250),Point(130,250),Point(220,160),Point(200,160),
Point(270,90),Point(250,90),Point(300,40)]);
Pen.Color:=RGB(128,64,0); //установка цвета пера (оттенок коричневого)
Brush.Color:=RGB(128,64,0); //установка цвета заливки (оттенок коричневого)
{Рисование ствола}
PolyGon([Point(350,251),Point(350,301),Point(250,301),Point(250,251)]);
End; end; end.