Delphida massivlar bilan ishlash algoritmlarga doir misollar 1-masala


Download 257.5 Kb.
bet4/7
Sana02.02.2023
Hajmi257.5 Kb.
#1146880
1   2   3   4   5   6   7
Bog'liq
Delphida ishlash algoritmlarga doir misollar

3.1- masala. Y=X^2 ning [0,1] oraliqda 0,1 qadam bilan qiymatlar jadvalini aniqlang.
procedure TForm1.Button1Click(Sender: TObject);
var a,b:byte;
n,y,x:real;s1,s2:string;
begin
a:=strtoint(edit1.Text);
b:=strtoint(edit2.Text);
n:=strtofloat(edit3.Text); x:=a;
memo1.Clear;
repeat y:=sqr(x);
str(x:2,s1);str(y:5,s2);
memo1.lines.Add('x='+s1+' y='+s2);
x:=x+n;
until x>=b;
end; end.

3.2- masala. N natural son va X haqiqiy sonlar berilgan. Quyidagi yig’indini hisoblang.
sinx+sin 2x+...sinnx
Yechish. Izlanayotgan yig’indini S bilan belgilaymiz.
procedure TForm1.Button1Click(Sender: TObject);
var n,i:byte; x,s:real;
begin
n:=strtoint(edit1.text);
x:=strtofloat(edit2.text);
s:=0; x:=sin(x);
for i:=1 to n do
s:=s+exp(i*ln(x));
edit3.text:=floattostr(s);
end;
end.
3.3- masala. N! Aniqlansin. Bunda N natural son.
Yechish. N<34 bo’lganda natural sonlar faktorialini hisoblash mumkin.
procedure TForm1.Button1Click(Sender: TObject);
var n,i:integer; f:int64;
begin
n:=strtoint(edit1.Text);
f:=1;
for i:=1 to n do
f:=f*i;
edit2.Text:=inttostr(f);
end;
end.
3.4- masala. 1dan 20 gacha natural sonlar kvadratlari yig’indisini toping.
Yechish. Izlanayotgan yig’indini S bilan belgilaymiz.
procedure TForm1.Button1Click(Sender: TObject);
var n,i:integer; f:int64;
begin
n:=strtoint(edit1.Text);
f:=0;
for i:=1 to n do
f:=f+sqr(i);
edit2.Text:=inttostr(f);
end;
end.
3.5- masala. A sonining N darajasini takrorlash buyrug’i yordamida hisoblang.
Yechish. A sonning n – darajasiga teng kattalikni y bilan belgilaymiz.
procedure TForm1.Button1Click(Sender: TObject);
var n,i,a,f:integer;
begin
n:=strtoint(edit1.Text);
a:=strtoint(edit2.Text);
f:=1;
for i:=1 to n do f:=f*a;
edit3.Text:=inttostr(f);
end;
end.

Download 257.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling