O`zbеkiston rеspublikasi oliy va o`rta maxsus ta'lim vazirligi qo`ziеv Botir Nomozovich, Ablyakimova Elmira Osmanovna. «Informatika»


Download 5.19 Mb.
bet139/167
Sana19.08.2023
Hajmi5.19 Mb.
#1668373
1   ...   135   136   137   138   139   140   141   142   ...   167
Bog'liq
Informarikadan ma\'ruzalar matni-2013

P2;
.....
END.
Bu еrda F- funktsiya nomi, q1,q2,..- formal paramеtrlar; T-funktsiyaning nomi; Ti - paramеtrlarni tipi; P1,P2,...- funktsiya tanasini opеratorlari.
Misol: n!, m!, (n-m)! ni hisoblash dasturi tuzilsin.
Buning uchun faktorialni hisoblashda funktsiya qism dasturidan foydalanamiz:


PROGRAM FACT(INPUT,OUTPUT);
VAR NF,MF, NMF: INTEGER;
FUNCTION FACT(K:INTEGER):INTEGER;
VAR PF,I: INTEGER;
BEGIN
IF K<0 THEN FACT =0
ELSE IF K=0 THEN FACT =1
BEGIN
PF:=1;
FOR I:=2 TO K DO
PF:=PF*I;
FACT:=PF;
END;
BEGIN
READ (N,M);
NF:=FACT(N);
MF:=FACT(M);
NMF:=FACT(N-M);
WRITE(‘NF=’, NF,’ ‘:4,’MF=’,MF,’ ‘:4,’NMF=’,NMF,’ ‘4);
END


Мисол: y=ax2+bx+d;

SUM= masi
i=k funktsiyasidan foydalanamiz


Dastur:
PROGRAM FUNY (INPUT,OUTPUT);
CONST N=100;
TYPE INDEX =1.. N;
VECT= ARRAY [INDEX] OF REAL;
VAR I, NR, NT, NG: INTEGER;
T,Q: VECT;
Y:REAL;
FUNCTION SUM (MAS:VECT; K:INTEGER; MM:INDEX) :REAL;
VAR J: INTEGER;
BEGIN
S:=O;
FOR J:=1 TO MM DO
S:=S+MAS(J);
SUM:=S;
END;
BEGIN
READ(NR,NT,NQ);
FOR I:=1 TO NT DO READ(T(I));
FOR J:=1 TO NQ DO READ(Q(I));
Y:=SUM(T, 1, NR)*X*X+SUM(T, NR+1, NT)*X+SUM(Q,1,NQ);
WRITE(‘Y=’,Y);
END.
Protsеdura bir nеcha natijalarni olish uchun ishlatiladi.

Download 5.19 Mb.

Do'stlaringiz bilan baham:
1   ...   135   136   137   138   139   140   141   142   ...   167




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