1- dars. Mavzu: Masalalarni kompyuterda yechish bosqichlari Darsning texnologik xaritasi




Download 1,92 Mb.
bet155/208
Sana23.07.2021
Hajmi1,92 Mb.
#15865
1   ...   151   152   153   154   155   156   157   158   ...   208
1- misol.[20, 83], [178, 391], [211, 746] oraliqlardagi barcha butun sonlar yig'indisini topish dasturini tuzing.

Yechish. Berilgan uchta oraliqdagi butun sonlarning yig'indisini hisoblash uchun parametrli takrorlash operatoridan uch marta foydalanishga to'g'ri keladi. Masalani berilgan oraliqning boshlang'ich va oxirgi qiymat­larini parametr sifatida olib, shu oraliqdagi butun sonlarning yig'indisini hisoblovchi funksiyadan foydalanib ham yechish mumkin.

Program Summa;

Var i, s, si, s2, s3 : Integer;

Function Sum(nl, n2:Integer):Integer;

Begin


s:=0; For i:=nl To n2 Do s:=s+i; Sum:=s;

End;


BEGIN

Sl:= Sum(20,83); s2 := Sum(178,391); s3:=Sum(211,746);


2-misol. Uchburchakning berilgan tomonlari bo'yicha, uning baland- liklarini aniqlovchi dastur tuzing.

Program Uchburchak_balandligi; Var a, b, c, ha, hb, he: real;

Function H_UB(a, b, c: real): real; { a, b, c — Uchburchak tomonlari } Var yp, s: real;

Begin


yp:= (a+b+c)/2; {Perimetr yarmini hisoblash } s:= Sqrt(yp*(yp~a)*(yp~b)*(yp~c)); {Yuza hisoblash} H_UB:= 2*s/a; {Funksiyaga qiymat berildi }

End; Begin

Write('Uchburchak tomonlari (a,b,c) kiritilsin'); Readln(a,b,c); ha:= H_UB(a, b, c); hb:= H_UB(b, a, c); hc:= H_UB(c, b, a);

Writeln('Uchburchak balandliklari: ');

Writeln('ha= ha:10:4, 'hb= hb:10:4, 'hc= hc:10:4);

Readln


End.

Download 1,92 Mb.
1   ...   151   152   153   154   155   156   157   158   ...   208




Download 1,92 Mb.

Bosh sahifa
Aloqalar

    Bosh sahifa



1- dars. Mavzu: Masalalarni kompyuterda yechish bosqichlari Darsning texnologik xaritasi

Download 1,92 Mb.