- •Задача 1
- •Interface
- •Implementation
- •Задача 2
- •Interface
- •Implementation
- •Задача 3
- •Задача 4
- •Implementation
- •Interface
- •Implementation
- •Var I:integer;
- •Задача 5
- •Implementation
- •Var k:integer; b,s:Extended;
- •Interface
- •Implementation
- •Interface
- •Var m:integer;
- •Implementation
- •Var X,y:Extended; I,x1,y1,xmax,ymax:Integer;
- •Задача 6
- •Implementation
- •Var k:integer; b,s:Extended;
- •Interface
- •Implementation
- •Var X,y:extended; I:integer;
- •Задача 7
- •Implementation
- •Interface
- •Implementation
- •Var x1,y1,ymax:integer;
- •Задача 9
- •Implementation
- •Interface
- •Implementation
- •Var X,y,h:extended; I:integer;
- •Задача 10
- •X1,y1,x2,y2,x3,y3,h:extended;
- •Implementation
- •Interface
- •Implementation
- •Var Xmax,ymax:integer;
- •Задача 11
- •Implementation
- •Interface
- •Implementation
- •Var tmp:string; I:integer;
- •Задача 12
- •Implementation
- •Interface
- •Implementation
- •Var I,k:integer; s:Set of char;
- •If not(st[I] in s) then
- •Include(s,st[I]);
- •Задача 13
- •Implementation
- •If savedialog1.Execute then
- •Interface
- •Implementation
- •Var ch:char;
- •Задача 14
- •Implementation
- •Interface
- •Implementation
- •Var n,i1,I:integer; tmp:string;
- •Задача 15
- •Implementation
- •If SaveDialog1.Execute then
- •Interface
- •Implementation
- •Var n:integer; ch:char;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
var m:integer;
Type Fun=Function(x:extended):extended;
Procedure Resh(a,b:extended; n:Integer; Sx:Fun; Var Fl:TextFile);
Implementation
Procedure Resh;
var x:extended; i:integer;
begin
x:=a;
for i:=1 to n+1 do
begin
writeln(fl,'x= '+FloatToStr(x)+' '+'S(x)= '+ FloatToStrF(Sx(x),fffixed,4,3));
x:=x+(b-a)/n;
end;
end;
end.
Задача 4
Составить и оформить в виде отдельного модуля подпрограмму удаления из динамического массива a из n целых чисел всех четных чисел сдвигая оставшиеся элементы на место удаленных (дополнительный массив не использовать). Вывести размер n1 полученного массива
Формальные параметры: a : Pmas1, n, n1.
Составить программу - обработчик события в которой при нажатии кнопки организованы ввод исходных данных в массив a из TStringGrid1 длиной n, обращение к подпрограмме, вывод исходных данных и результатов в окно TStringGrid2 длины n1.
var
Form1: TForm1;
n,i:integer;
a:Pmas; n1:integer;
Implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
Edit1.Text:='5'; N:=StrToInt(Edit1.text);
For i:=1 to n do stringGrid1.Cells[i-1,0]:=IntToStr(Random(10));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
N:=StrToInt(Edit1.text); StringGrid1.ColCount:=n;
For i:=1 to n do stringGrid1.Cells[i-1,0]:=IntToStr(Random(10));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetMem(a,4*n);
For I:=0 to n-1 do A[i]:=StrToInt(StringGrid1.Cells[i,0]);
Resh(n,a,n1);
StringGrid2.ColCount:=n1+1;
for i:=0 to n1 do StringGrid2.Cells[i,0]:=IntToStr(a[i]);
FreeMem(a,4*n);
end;
end.
unit Unit2;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
Type Mas=array [0..0] of integer;
Pmas=^Mas;
Procedure Resh(n:integer; var a:Pmas; Var n1:integer);
Implementation
procedure resh;
Var I:integer;
begin
n1:=-1;
for i:=0 to n-1 do
if a[i] mod 2=1 then
begin
n1:=n1+1;
a[n1]:=a[i];
end;
end;
end.
Задача 5
Составить и оформить в виде отдельного модуля подпрограмму вывода графика функции f(x) на интервале [a, b] с шагом h=(b-a)/n с прорисовкой прямоугольника осей, отстоящего от границ окна TImage на p пикселей.
Формальные параметры: a, b, n, f(x), M :TImage
Составить обработчик события в котором при нажатии кнопки организованы ввод исходных данных, обращение к подпрограмме для вывода графика функции
(S(x) описать в вызывающей программе, m передать через глобальную переменную), вывод исходных данных и результатов компоненту TImage.
var
Form1: TForm1;
a,b:extended;
N:integer;
Implementation
{$R *.dfm}
Function Sx(x:extended):extended;
Var k:integer; b,s:Extended;
begin
k:=1; s:=0; b:=1;
while k<m do
begin
b:=b*x/k;
S:=S+b;
k:=k+1;
end;
Result:=s;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:='1'; Edit2.Text:='5'; Edit3.Text:='10';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
M:=5;
a:=StrToFloat(Edit1.text);
b:=StrToFloat(Edit2.text);
n:=StrToInt(Edit3.text);
Resh(a,b,n,sx,Image1);
end;
end.
unit Unit2;
