close

Вход

Забыли?

вход по аккаунту

?

отчет по практике(7)

код для вставкиСкачать
??????????.
??????? ????????..................................................................................3
1.??????? ??????????.
1.1 ???????? ??????.................................................................................4
1.2 ???????? ????? ? ?????? ????????????................................................5 1.3 ?????? ??????????.............................................................................6 1.4 ????????? ???????.............................................................................9 2. ??????????? ????????
2.1 ???????? ??????...............................................................................13
2.2 ???????? ????? ? ?????? ????????????...............................................14
2.3 ?????? ??????????...........................................................................15
2.4 ????????? ???????...........................................................................17 3.????????? TStringGrid
3.1 ???????? ??????................................................................................19
3.2 ???????? ????? ? ?????? ????????????................................................20
3.3 ?????? ??????????............................................................................21
3.4 ????????? ???????............................................................................29
4. ?????????TMemo
4.1 ???????? ??????................................................................................34
4.2 ???????? ????? ? ?????? ????????????................................................35
4.3 ?????? ??????????............................................................................36
4.4 ????????? ???????............................................................................39
?????? ??????????.................................................................................
??????? ????????.
N???????????? ????? ? ??????????? ??????????1?????????? ? Borland Delphi 7.0. ?????? Delphi. ??????? ???????, ?????, ?????????? ?????. ???????? ? ?????? ????????? ?????????? ???????? ?????. ?????????? ???????? ???????. ????????? ??????? Delphi. ?????????????????? ??????????.27.06.20112?????????? ?????????????? ??????? ?1 ? ?2 ???????? ????????. ?????????? ? ??????? ????????. ????????????. ????????? ?????? ?????.28.06.2011-29.06.20113?????????? ?????? ?????????? ? ???????????? ??????? ? ???? ???????????? ???? ???????? ? ??????? ? ?????.28.06.2011-29.06.20114????????? ???????? ? Borland Delphi. ????????????? ? ??????????? ??????????? StringGrid ? Memo. ???????? ? ?????? ???????????. ?????????? ??????? ???????? ??????????.30.06.20115?????????? ??????? ???????? ????????.30.06.2011-01.07.20114?????????? ???????????? ?? ????????????? ??????????02.07.2011-03.07.20115?????? ??????09.07.2011
1.1 ???????? ??????.
??????? ??????????, ??????????? ????????? ??????????: ? ????????? ???? ????????????? ????? ?????. ? ???? ????? ????? ????????? ?????????? ? ???, ????????????? ??? ?????, ????????????? ??? ????. ? ???? ?????? ????? ????????? ?????????? ? ???????? ?????.
??????????: ????????? ?????? ?????????? ??? ?????? ??? ???????? ???????????? ???????? ?????. ??????? ??? ???? ??????????????? ????????? ? ????????? ????????? ???? ????????.
1.2 ???????? ????? ? ?????? ????????????.
????? Label1 ???????????? ??? ????????? ????????????. ???? Edit1 ???????????? ??? ????? ?????.
?? ??????? ?????? Button1 ???????????? ???????? ????? ? ????? ????????????? ??? ????? ???? ?????????????.
? ????? Label2 ????????? ?????????? ? ??? ???????????? ??? ???????????? ????????? ?????.
? ????? Label3 ????????? ?????????? ? ???????? ?????.
1.3 ?????? ??????????.
??? ??????? ?????????.
????? ?? ???????.
1.4 ????????? ???????.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a, c: Integer;
b: Real;
begin
Label2.Caption:='????? ?';
Label3.Caption:='????? b';
Label4.Caption:='????? c';
for c := 1 to 20 do
for a := 1 to c-1 do
begin
b := SQRT(c*c - a*a);
if int(b) = b then
begin
Label2.Caption:=Label2.Caption+Chr(10)+IntToStr(a)+Chr(10);
Label3.Caption:=Label3.Caption+Chr(10)+FloatToStr(b)+Chr(10);
Label4.Caption:=Label4.Caption+Chr(10)+IntToStr(c)+Chr(10);
end;
end;
end;
end.
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Label3: TLabel;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ch:integer;{?????}
rez:integer;{??? ????????}
begin
if Edit1.Text=''
then
begin
Label3.Caption:='??????? ?????!';
Label2.Caption:=' ';
Edit1.setFocus;
Exit;
end;
ch:=StrToInt(Edit1.Text);
if ch>0
then Label2.Caption:=Edit1.Text+' ????????????? ?????';
if ch<0
then Label2.Caption:=Edit1.Text+' ????????????? ?????';
rez:=ch mod 2;
if rez=0
then Label3.Caption:=Edit1.Text+' ????? ??????'
else Label3.Caption:=Edit1.Text+' ????? ????????';
if ch=0
then
begin
Label2.Caption:=' ??? ????? 0';
Label3.Caption:=' ';
end;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
case Key of
'0'..'9',Chr(8): ; {????? ? <BackSpace>}
'-':if (pos('-',Edit1.Text)<>0)or(pos('-',Edit1.Text)>1)
then Key:=Chr(0);
chr(13): Button1.Click ; {????????? ???????? ? ??????????????? ?????}
else Key:=Chr(0); {??????????? ??????? ?? ??????????}
end;
end;
end.
2.1 ???????? ??????.
????? ? ??????? ? ???? ????? ? ??????? ??? ??????????? ????? a,b,c ?? ????????? ?? 1 ?? 20, ??? ??????? ??????????? ????????? a^2+b^2=c^2 ? ?????? Label1 ? Label2.
2.2 ???????? ????? ? ?????? ????????????.
????? Label1???????????? ??? ?????? ????????? ????????????.
?????? Button1 ???????????? ??? ?????? ??????????.
????? Label2 ???????????? ??? ????? ????? ?.
????? Label3 ???????????? ??? ????? ????? b.
????? Label4 ???????????? ??? ????? ????? ?.
2.3 ?????? ??????????.
??? ??????? ?????????.
??? ??????? ?????? "??????". 2.4 ????????? ???????.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a, c: Integer;
b: Real;
begin
Label2.Caption:='????? ?';
Label3.Caption:='????? b';
Label4.Caption:='????? c';
for c := 1 to 20 do
for a := 1 to c-1 do
begin
b := SQRT(c*c - a*a);
if int(b) = b then
begin
Label2.Caption:=Label2.Caption+Chr(10)+IntToStr(a)+Chr(10);
Label3.Caption:=Label3.Caption+Chr(10)+FloatToStr(b)+Chr(10);
Label4.Caption:=Label4.Caption+Chr(10)+IntToStr(c)+Chr(10);
end;
end;
end;
end.
3.1 ???????? ??????.
?????????? ?????????? ? ??????: ?????, ?????, ????????, ????. ????????????? ????? ?????? ?? ?????? ?????. ??????????? ??????? ????????? ?????? ?? ????? ????. ???? ?????? ???????, ??????? ?????? ? ????????? ?????, ? ????? - ????????? ?? ????. ????????? ?????????? ??????????? ?????????.
3.2 ???????? ????? ? ?????? ????????????.
????? Label1? Label2 ???????????? ??? ?????? ????????? ????????????.
????? Label3 ???????????? ??? ?????? ?????????? ?????? ? ?????????? ??????????? ?????????.
?????? Button1 ???????????? ??? ??????? ??????.
?????? Button2 ???????????? ??? ??????? ?????????? ???????.
???? Edit1 ???????????? ??? ????? ?????? ??????? ?????.
????????? StringGrid1 ???????????? ??? ?????? ???????.
3.3 ?????? ??????????.
??? ??????? ?????????.
?????? ?? ?????????? ??? ????? ????????? ?????????.
?????? ????? ??????????.
?????? ?? ?????????? ??? ????????????? ????????? ????????.
?????? ????? ??????????.
????????? ?????.
??????? ?????.
3.4 ????????? ???????.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
kn= record
nazv : string;
avt : string;
nomer : integer;
cena : integer;
end;
TForm1 = class(TForm)
Label1: TLabel;
StringGrid1: TStringGrid;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure StringGrid1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
mass:array[1..3] of kn = (( nazv:'???????????'; avt:'???????'; nomer:168; cena:320),
(nazv:'????? ???????'; avt:'????????'; nomer:126; cena:546),
(nazv:'??????'; avt:'?????????'; nomer:264; cena:555)
);
var
Form1: TForm1;
a:array [1..20] of kn;
size:integer;
implementation
{$R *.dfm}
procedure TForm1.StringGrid1Click(Sender: TObject);
var i:integer;
begin
Form1.StringGrid1.Cells[0, 0]:='????????';
Form1.StringGrid1.Cells[1, 0]:='?????';
Form1.StringGrid1.Cells[2, 0]:='?????';
Form1.StringGrid1.Cells[3, 0]:='????';
For i:=1 to 3 do
begin
if (Form1.StringGrid1.Cells[0, i]='')and (Form1.StringGrid1.Cells[1, i]='')then
begin
Form1.StringGrid1.Cells[0, i]:=mass[i].nazv;
Form1.StringGrid1.Cells[1, i]:=mass[i].avt;
Form1.StringGrid1.Cells[2, i]:=IntToStr(mass[i].nomer);
Form1.StringGrid1.Cells[3, i]:=IntToStr(mass[i].cena);
end
else break;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
obr:integer;
verh:integer;
niz: integer;
sred:integer;
found:boolean;
n:integer;
i,size:integer;
//vsp:array[1..3] of kn;
begin
SIZE:=0;
for i:=1 to 20 do
if Form1.StringGrid1.Cells[0, i]<>''then
begin
a[i].nazv:=Form1.StringGrid1.Cells[0, i];
a[i].avt:=Form1.StringGrid1.Cells[1, i];
a[i].nomer:=StrToInt(StringGrid1.Cells[2, i]);
a[i].cena:=StrToInt(StringGrid1.Cells[3, i]);
SIZE:=SIZE+1;
end
else break;
obr := StrToInt(Edit1.text);
verh:=1;
niz := SIZE; n := 0;
found := FALSE; label3.caption := '';
// ???????? ????? ? ???????
repeat
begin
sred := Trunc((niz - verh) / 2) + verh;
n := n + 1;
if a[sred].nomer = obr then
found := TRUE
else
if obr < a[sred].nomer then
niz := sred - 1
else
verh := sred + 1;
end;
until
(verh > niz) or found;
if found then
label3.caption := label3.caption
+'????? ???????. '+#13+#13
+'????????: '+a[sred].nazv+#13
+'?????: '+a[sred].avt+#13
+'?????: '+IntToStr(a[sred].nomer) + #13
+'????: '+IntToStr(a[sred].cena) + #13+#13+#13
+'?????????? ?????????: '+ IntToStr(n)
else
label3.caption := label3.caption
+'????? ?? ???????.'+ #13+#13+#13
+'?????????? ????????? '+ IntToStr(n);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i,j:integer;
b:kn;
begin
SIZE:=0;
for i:=1 to 20 do
if Form1.StringGrid1.Cells[0, i]<>''then
begin
a[i].nazv:=Form1.StringGrid1.Cells[0, i];
a[i].avt:=Form1.StringGrid1.Cells[1, i];
a[i].nomer:=StrToInt(StringGrid1.Cells[2, i]);
a[i].cena:=StrToInt(StringGrid1.Cells[3, i]);
SIZE:=SIZE+1;
end
else break;
//?????????? ?? ?????? ?????
for j:=1 to SIZE-1 do
for i:=1 to SIZE-j do
if a[i].nomer>a[i+1].nomer then
begin
b:=a[i];
a[i]:= a[i+1];
a[i+1]:=b
end;
for i:=1 to SIZE do
begin
Form1.StringGrid1.Cells[0, i]:=a[i].nazv;
Form1.StringGrid1.Cells[1, i]:=a[i].avt;
Form1.StringGrid1.Cells[2, i]:=IntToStr(a[i].nomer);
Form1.StringGrid1.Cells[3, i]:=IntToStr(a[i].cena);
end;
end;
end.
4.1 ???????? ??????.
? Memo- ???? ???????? ????? ?? ?????? ? ??????. ????????????? ??? ????? ? ??????? ??????????? ??? ???????? (?????????? ? ??????? ??????) ??????? ?????????. ????????? ?? ????? ?????? ?????????? ? ?????? ?? ???????????.
4.2 ???????? ????? ? ?????? ????????????.
????? Label1 ???????????? ??? ?????? ????????? ????????????.
???? Memo1 ???????????? ??? ?????? ????????? ? ???????????????? ???????.
?????? Button1???????????? ??? ??????? ??????????.
???? CheckBox1???????????? ?????????? ?? ??????????? ???? ????????.
4.3 ?????? ??????????.
??? ??????? ?????????.
?????????? ?? ???????????.
?????????? ?? ????????.
4.4 ????????? ???????.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Memo1: TMemo;
Button1: TButton;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const SIZE=32; // ?????? ???????
var a : array [1..SIZE] of string[30];
n: integer ; // ?????????? ?????, ????????? ? ???? Memo
i,j: integer; // ?????? ???????? ???????
st:string;
begin
n:=Memo1.Lines.Count;
if n = 0 then
begin
ShowMessage('???????? ?????? ?? ???????!');
Exit; // ????? ?? ????????? ????????? ???????
end;
// ? ???? Memo ???? ?????
if n > SIZE then begin
ShowMessage ( '?????????? ????? ????????? ?????? ???????.');
n:=SIZE; // ????? ??????? ?????? ?????? SIZE ?????
end;
for i:=1 to n do
a[i]:=Form1.Memo1.Lines[i-1]; // ?????? Memo ????????????? ? ????
for i:=2 to n do
begin
st:=a[i];
j:=i-1;
if CheckBox1.State = cbChecked then
begin
while (j>=1) and (a[j]>st) do
begin
a[j+1]:=a[j];
j:=j-1;
end;
end
else
begin
while (j>=1) and (a[j]<st) do
begin
a[j+1]:=a[j];
j:=j-1;
end;
end;
a[j+1]:=st;
end;
memo1.Text:='';
for i:=1 to n do
Memo1.Lines.Text:=Memo1.Lines.Text+ a[i]+#13;
end;
end.
?????? ??????????.
1. ??????? ?. ?. ???????????????? ? Turbo Pascal 7.0 ? Delphi. ???????????.- ???: ???- ?????????, 2002 - 416 ?.
2. ??????? ?. ?. ?????? ???????????????? ? Delphi 7. ???????????.- ???: ???- ?????????, 2003.- 608 ?.
3. ?????? ?.?., ????????? ?.?. Delphi 6. ???????? ?????? ???????????. - ???: ???- ?????????, 2002.- 1152 ?.
4. ?????? ?.?., ????????? ?.?. Delphi. ??????? ?????. 2
Документ
Категория
Без категории
Просмотров
23
Размер файла
534 Кб
Теги
практике, отчет
1/--страниц
Пожаловаться на содержимое документа