type TForm1 = class(TForm) Image1: TImage; Button1: TButton; OpenDialog1: TOpenDialog; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin if OpenDialog1.Execute then begin Image1.Picture.LoadFromFile(OpenDialog1.FileName); Image1.Stretch:=true; Image1.Left:=form1.Width div 2-image1.Width div 2; Image1.top:=form1.Height div 2-image1.Height div 2; end end;
1) var a:array [1..10] of integer; i,sum:integer; begin randomize; sum:=0; for i:=1 to 10 do begin a[i]:=random(100)-50; write (a[i],' '); if a[i] < 0 then sum:=sum+a[i]; end; writeln; writeln ('Summa: ',sum); readln; end.
2) var a:array [1..10] of integer; i,max,index:integer; begin for i:=1 to 10 do begin write ('A[',i,'] = '); readln (a[i]); end; max:=a[1]; index:=1; for i:=2 to 10 do if a[i] > max then begin max:=a[i]; index:=i; end; writeln ('Max: ',max,'.Index: ',index); readln; end.
3) var a:array [1..10] of integer; max,min,i,temp:integer; begin randomize; for i:=1 to 10 do begin a[i]:=random(50); write (a[i],' '); end; writeln; max:=1; min:=1; for i:=2 to 10 do if a[i] > a[max] then max:=i else if a[i] < min then min:=i; writeln ('Max: ',a[max]); writeln ('Min: ',a[min]); temp:=a[min]; a[min]:=a[max]; a[max]:=temp; for i:=1 to 10 do write (a[i],' '); end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
Image1.Picture.LoadFromFile(OpenDialog1.FileName);
Image1.Stretch:=true;
Image1.Left:=form1.Width div 2-image1.Width div 2;
Image1.top:=form1.Height div 2-image1.Height div 2;
end
end;
end.
var a:array [1..10] of integer;
i,sum:integer;
begin
randomize;
sum:=0;
for i:=1 to 10 do
begin
a[i]:=random(100)-50;
write (a[i],' ');
if a[i] < 0 then sum:=sum+a[i];
end;
writeln;
writeln ('Summa: ',sum);
readln;
end.
2)
var a:array [1..10] of integer;
i,max,index:integer;
begin
for i:=1 to 10 do
begin
write ('A[',i,'] = ');
readln (a[i]);
end;
max:=a[1];
index:=1;
for i:=2 to 10 do
if a[i] > max then
begin
max:=a[i];
index:=i;
end;
writeln ('Max: ',max,'.Index: ',index);
readln;
end.
3)
var a:array [1..10] of integer;
max,min,i,temp:integer;
begin
randomize;
for i:=1 to 10 do
begin
a[i]:=random(50);
write (a[i],' ');
end;
writeln;
max:=1;
min:=1;
for i:=2 to 10 do
if a[i] > a[max] then max:=i else
if a[i] < min then min:=i;
writeln ('Max: ',a[max]);
writeln ('Min: ',a[min]);
temp:=a[min];
a[min]:=a[max];
a[max]:=temp;
for i:=1 to 10 do write (a[i],' ');
end.