.


:




:

































 

 

 

 


3. .




4. ***999 , 13,17,19.

procedure TForm1.Button1Click(Sender: TObject);

var a,n, i:integer;

begin

for i:=100 to 999 do begin

n:=1000*i+999;

if ((n mod 13)=0) and ((n mod 17)=0) and ((n mod 19)=0)

then

memo2.lines.add(inttostr(n));

end;

end;

 

procedure TForm1.Button2Click(Sender: TObject);

begin

memo2.clear;

end;

end.

 

// 1) n:= 100000, 999999,1

// 2) if ((n mod 13)=0) and ((n mod 17)=0) and ((n mod 19)=0)

9. , . , , 2,3,4,5 6 . 7 , . .

procedure TForm1.Button1Click(Sender: TObject);

var n:integer;

begin

n:=strtoint(edit1.Text);

for n:=1 to n do

if (n mod 2=1) and (n mod 3=1) and (n mod 4=1) and (n mod 5=1) and (n mod 6=1)

and (n mod 7=0)

then memo1.Lines.Add(inttostr(n))

end;

procedure TForm1.edit1onkeypress(Sender: TObject; var Key: Char);

begin

case key of

'0'..'9',#8:;

#13: button1.setfocus;

else key:=chr(0);

end;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

memo1.Clear;

end;

end.

 

// 1) n:=1,500,1

// 2) if (n mod 2=1) and (n mod 3=1) and

(n mod 4=1) and (n mod 5=1) and (n mod 6=1)

 

4.

4. a[1..10]. ( :

Var form1: tform1;

a:array[1..10] of integer

max, i, k:integer;

procedure TForm1.Button1Click(Sender: TObject);

begin

max:=a[i-1];

for i:=2 to 10 do

if a[i]>max then

begin

max:=a[i];

k:=i;

end;

label1.caption:=inttostr(max);

label2.caption:=inttostr(k);

end;

// 1) for i:=2 to 10 do

If a[i]>max then

Random 4 9:

procedure TForm1.Button2Click(Sender: TObject);

begin

randomize;

for i:=1 to 10 do

begin

a[i]:=random(100); ( 9 -10, )

stringgrid1.cells[i-1,0]:=inttostr(a[i]);

end;

end;

end.(? )

 

9. .

procedure TForm1.Button1Click(Sender: TObject);

var i,k:integer;

begin

randomize;

for i:=1 to 25 do

begin

a[i]:=random(20)-10;

stringgrid1.Cells[i-1,0]:=inttostr(a[i]);

end;

end;

procedure TForm1.Button2Click(Sender: TObject);

var i,k,l:integer;

begin

k:=1;

for i:=1 to 25 do begin

if (a[i]>0) then

begin

b[k]:=a[i];

k:=k+1;

end;

stringgrid2.cells[k-1,0]:=inttostr(b[k]);

begin

for l:=1 to k do begin

n:=b[3]+b[6];

label1.caption:=inttostr(n);

end;

end;

end;

end;

procedure TForm1.Button3Click(Sender: TObject); // 2

var

m, n: Integer;

begin

with StringGrid2 do

for m:= 0 to ColCount - 1 do

for n:= 0 to RowCount - 1 do

Cells[m, n]:= '';

end;

end.

//1)- n:=1,25,1 2) - a[i]>0 3) - l:=1,k,1

5. .

4. , . . ( input.txt output.txt).

procedure TForm1.Button2Click(Sender: TObject);

begin

if opendialog1.Execute then

memo1.Lines.LoadFromFile(opendialog1.FileName);

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

if savedialog1.execute then

memo1.Lines.SaveToFile(savedialog1.filename+'.txt');

end;

procedure TForm1.Button1Click(Sender: TObject);

var n,i,k:integer;s:string;

begin

assignfile(f1,'input.txt');

assignfile(f2,'output.txt');

reset(f1);

read(f1,s);

rewrite(f2);

k:=0;

for i:=1 to length(s) do

begin

if ((s[i]='') or (s[i]='')) then

k:=k+1;

end;

writeln(f2,k);

memo2.lines.add(inttostr(k));

closefile(f1);

closefile(f2);

end;

end.

// 1) i:=1,length(s),1

// 2) if ((s[i]='') or (s[i]=''))

9. , . ( input.txt output.txt).

procedure TForm1.Button1Click(Sender: TObject);

var i,c:integer;s:string;

begin

assignfile(f1,'input.txt');

assignfile(f2,'output.txt');

reset(f1);

read(f1,s);

rewrite(f2);

for i:=1 to length(s) do

begin

if (s[i]='.') then

delete(s,i,c);

c:=length(s)-i;

end;

writeln(f2,s);

memo2.Lines.add(s);

closefile(f1);

closefile(f2);

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

if opendialog1.Execute then

memo1.Lines.LoadFromFile(opendialog1.FileName);

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

if savedialog1.execute then

memo1.Lines.SaveToFile(savedialog1.filename+'.txt');

end;

end.

//1) i:=1,length(s),1

//2) if (s[i]='.')

 

6.

4. 100 , , .

procedure TForm1.Button1Click(Sender: TObject);

var

i:integer;

x,y:real;

begin

for i:= 1 to 100 do // 1)

begin

x:=Image1.Width div 2+(Image1.Width div 2)*sin(i/2); //2)

y:=Image1.Height div 2+(Image1.Height div 2)*cos(i/2); //3)

with Image1.Canvas do

begin

MoveTo(Image1.Width div 2, Image1.Height div 2); //4)

LineTo(round(x),round(y)); // 5)

end;

end;

end;

end.

9. .

function f(x:real):real;

begin

f:=x*x*x;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

x1, x2, y1, y2, x, y, dx, mx, my: real;

l, b, w, h, x0, y0: integer;

begin

l:= 10;

b:= Form1.image1.ClientHeight - 20;

h:= Form1.image1.ClientHeight - 40;

w:= Form1.image1.Width - 40;

x1:= 0;

x2:= 5;

dx:= 0.01;

y1:= f(x1);

y2:= f(x1);

x:= x1;

repeat

y:= f(x);

if y < y1 then y1:= y; //2)

if y > y2 then y2:= y; //3)

x:= x + dx;

until (x >= x2); //1)

my:= h / abs(y2 - y1);

mx:= w / abs(x2 - x1);

x0:= l;

y0:= b - Abs(Round(y1 * my));

with form1.Canvas do

begin

MoveTo(l, b); LineTo(l, b - h);

MoveTo(x0, y0); LineTo(x0 + w, y0);

x:= x1;

repeat

y:= f(x);

Pixels[x0 + Round(x * mx), y0 Round(y * my)]:= clRed;

x:= x + dx;

until (x >= x2); //4)

end;

end;

procedure TForm1.formresize(Sender: TObject);

begin

form1.image1.Canvas.FillRect(Rect

(0, 0, ClientWidth, ClientHeight));

end;

end.

end;

end;

end.

 

 

:

Delphi, , . : button, edit, memo, stringgrid, label, opendialog, savedialog. : caption, text, lines. , onkeypress, showmessage. (halt), (form().show), memo(memo( memo).clear).

Delphi canvas.

 

:

1. .. Delphi . .: - , 2004.-299 .:.

2. ., ., . . .: -; , 1998,592 .

3. .. Delphi.-2- ., . ./.. , .. . .-, 2008.-576.:. +CD-ROM

4. Google

 

 





:


: 2017-01-28; !; : 193 |


:

:

- , .
==> ...

1912 - | 1711 -


© 2015-2024 lektsii.org - -

: 0.046 .