4.1
: k=1, 3, 5,, 27; m-
S.
: k.
: S.
4.2.
( R3) .
R3
k,j,m: ; { }
S,: ; { }
o
m
k:=1;
1
k<=27
s:=0;
2
j 2 m
p:=sin(j/power(2,k)-pi)*sin(j/power(2,k)-pi);
2
s:=s+p;
k:=k+2;
1
x,y,sum,pr,min,max ;
.
4.3.
4.3.1.
4.3.2. Delphi
procedure TForm1.Button1Click(Sender: TObject);
var j,m,k:integer; //
s,p:real; //
begin
k:=1; //
m:=StrToint(edit1.Text); // m
while k<=27 do begin
s:=0; //
for j:=2 to m do
begin
p:=sin(j/power(2,k)-pi)*sin(j/power(2,k)-pi); //
s:=s+p; // s
end;
k:=k+2; //
label1.Caption:=label1.Caption+FloatToStr(s)+#13;
end;
4.4.
. , , . .
: m=50
: 24,8989781328588
25,1169588619545
25,3662974146517
2,539528579046
0,016342383504
0,00063961258
0,0000399761
0,000002499
0,00000016
0
: m=20
: 9,50034686946757
12,0713899987859
2,58078768491726
0,17421466859864
0,0109408616025
0,00068400921
0,0000427514
0,000002672
0,00000017
: m=1000
: 499,501158172292
502,10514496015
502,618179656355
497,847352908721
589,043379439968
75,8782812670524
4,95968783864002
0,3108487101556
0,0194314406721
0,00121447831
0,00000759049
0,000004744
0, 0000003
4. 5.
.
5.
5.1
()
1) ()
2) () .
3) () .
: , [- 2; 2,5].
|
|
5.2.
R3
X:[0100]:; { }
I,n,imax:; { }
max:; { }
o
n:=memo1.Lines.Count;
max:=-x[0]; imax:=0;
1
i 0 n-1
x[i]:=strtofloat(memo1.Lines[i]);
(x[i]<=2.5) (x[i]>=-2) (x[i]>=max) max:=x[i]; imax:=I;
1
(imax) .
.
X:[0100]:; { }
I,n:; { }
max:; { }
o
;
n:= random(10);
1
i 0 n-1
memo2.lines.Add(floattostr(random(10)));
1
max:=-x[0]; imax:=0;
2
i 0 n-1
x[i]:=strtofloat(memo1.Lines[i]);
(x[i]<=2.5) (x[i]>=-2) (x[i]>=max) max:=x[i]; imax:=I;
2
(imax) .
.
(max) .
.
X:[0100]:; { }
I,n:; { }
max:; { }
o
n:=6;
1
i 0 n-1
memo3.lines.Add(inttostr(i));
1
max:=-x[0]; imax:=0;
2
i 0 n-1
x[i]:=strtofloat(memo1.Lines[i]);
(x[i]<=2.5) (x[i]>=-2) (x[i]>=max) max:=x[i]; imax:=I;
2
(imax) .
.
(max) ;
.
5.3.
5.3.1.
Delphi
procedure TForm1.Button1Click(Sender: TObject);
var max: real; x: array[0..100] of real; i,n: integer;
begin
n:=memo1.Lines.Count;
max:=-5;
for i:= 0 to n - 1 do
begin
x[i]:=strtofloat(memo1.Lines[i]);
if (x[i]<=2.5)and (x[i]>=-2) and (i>=max) then max:=i;
end;
label1.caption:=floattostr(max);
end;
procedure TForm1.Button2Click(Sender: TObject);
var max: real; x: array[0..100] of real; i,n: integer;
begin
Randomize;
n:=random(10);
for i:= 0 to n - 1 do
begin
memo2.lines.Add(floattostr(random(10)));
end;
max:=-5;
for i:= 0 to n - 1 do
begin
x[i]:=strtofloat(memo2.Lines[i]);
if (x[i]<=2.5)and (x[i]>=-2) and (i>=max) then max:=i;
end;
label2.caption:=floattostr(max);
end;
procedure TForm1.Button3Click(Sender: TObject);
var max: real; x: array[0..100] of real; i,n: integer;
begin
n:=6;
for i:= 0 to n - 1 do
begin
memo3.lines.Add(inttostr(i));
end;
max:=-5;
for i:= 0 to n - 1 do
begin
x[i]:=strtofloat(memo3.Lines[i]);
if (x[i]<=2.5)and (x[i]>=-2) and (i>=max) then max:=i;
end;
label3.caption:=floattostr(max);
end;
end.
5.4.
. , , . .
: :
6 1
-3
: :
6 0
: :
0 2
5. 5.
|
|