2. Tarmoqlanuvchi hisoblash jarayonlarini algoritmlash va dasturlash.
Oddiy tamoqlanuvchi hisoblash jarayonlarini algoritmlash
va dasturlash. To‘liq shartli tarmoqlanish jarayoni.
Tarmoqlanuvchi hisoblash jarayonlarini algoritmlash va dasturlashda shartli operatorlardan foydalaniladi.
Paskal algoritmik tilida shartli operatorlar quyidagi xizmatchi so‘zlar bilan ifodalanadi: IF (Agar), THEN (u
holda), ELSE (aks holda), GO TO (o‘tilsin __).
To‘liq shartlar to‘liq munosabatlar
,
,
,
,
,
,
va
,
yordamida hosil qilinadi.
Quyidagilar to‘liq shartlar hisoblanadi:
b
a
b
a
b
a
,
y
x
y
x
,
d
w
d
w
,
b
a
b
a
va hakozo. Bunday shartlarda 2,3,4-holatlarda bitta shartni
БОШЛАШ
Y = a + 2c
2
A,B,C,D
X = ay + c
Z = ax/b – y
3
Q = (2x+3y)/(2+Z
2
)
U = (X + Y)/Q + d
A,B,C,D,X,Y,Z,U,Q
ТАМОМ
20
tekshirish, birinchi holatda hohlagan ikkita shartni tekshirish etarli hisoblanadi, chunki qolgan shart avtomatik
tarzda bajariladi. Quyidagilar to‘liq shartlar bo‘laolmaydi:
b
c
b
a
b
a
,
y
x
z
x
,
d
w
x
a
,
b
a
d
c
va hakozo. Bunday hollarda barcha shartlar to‘liq
tekshirilishi zarur.
Misol.
.
,
2
,
,
2
2
d
x
agar
d
x
a
x
d
x
agar
x
d
c
ax
y
Masalani shartidan ko‘rinib turibdiki agar
x d
dan kichik yoki unga teng bo‘lsa
(x ≤ d)
y
ni birinchi
ifoda, ya’ni
2
x
d
c
ax
y
bo‘yicha hisoblaymiz, aks holda
y
ni ikkinchi ifoda, ya’ni
d
x
a
x
y
2
2
bo‘yicha hisoblaymiz. Bu masalaning sharti to‘lik, chunki bitta shart bajarilmasa ikkinchisi albatta bajariladi.
Quyida masalani hisoblash algoritmi va dasturi keltirilgan:
A)
Masalani echishning klassik varianti.
Hisoblash algoritmi
1
2
3
4
5
6
7
8
Paskal tilidagi dasturi
Program oddiy_tarmoqlanish;
Label 6,8;
Var a,c,d,x,y:real;
Begin
Write (‘a,c,d,x =’);
Read(a,c,d,x);
If x<=d then goto 6;
Y:=2*x*x+a*sqrt(x-d);
Writeln(‘hisoblash 2-
formula bo”yicha
bajarildi ‘, a,c,d,x,y);
goto 8;
6:Y:=(a*x+c)/sqrt(d-x+2);
Writeln(‘hisoblash 1-
formula bo”yicha
bajarildi ‘, a,c,d,x,y);
8:readln;
end.
d
x
d
x
a
x
y
2
2
“Ҳ-ш 1-ф.б.б”;
a,c,d,x,y
a, c, d, х
2
x
d
c
ax
y
БОШЛАШ
“Ҳ-ш 2-ф.б.б”;
a,c,d,x,y
+
21
Hisoblash ikkita tarmoq bo‘yicha amalga oshiriladi:
“HA” tarmog‘i – 1 , 2, 3, 6, 7, 8 bloklar ketma-ketligidir;
“YO‘Q” tarmog‘i - 1 , 2, 3, 4, 5, 8 bloklar ketma-ketligidir;
B) Masalani yechishning xususiy varianti.
Hisoblash algoritmi
1
2
3
4
5
6
Paskal tilidagi dasturi
Program oddiy_tarmoqlanish;
Label 6;
Var a,c,d,x,y:real;
Begin
Write (‘a,c,d,x =’);
Read(a,c,d,x);
If x<=d then
begin
Y:=(a*x+c)/sqrt(d-x+2);
Writeln(‘hisoblash 1-
formula bo”yicha
bajarildi ‘,
a,c,d,x,y); goto 6;
end;
Y:=2*x*x+a*sqrt(x-d);
Writeln(‘hisoblash 2-
formula bo”yicha
bajarildi ‘, a,c,d,x,y);
6:readln;
end.
Dasturni quyidagicha ham yozish mumkin
Program oddiy_tarmoqlanish;
Var a,c,d,x,y:real;
Begin
Write (‘a,c,d,x =’);
Read(a,c,d,x);
If x<=d then
begin
d
x
d
x
a
x
y
2
2
“Ҳ-ш 1-ф.б.б”;
a,c,d,x,y
Тамом
a, c, d, х
2
x
d
c
ax
y
БОШЛАШ
“Ҳ-ш 2-ф.б.б”;
a,c,d,x,y
+
22
Y:=(a*x+c)/sqrt(d-x+2);
Writeln(‘hisoblash 1-
formula bo”yicha
bajarildi ‘,
a,c,d,x,y);
end
else
begin
Y:=2*x*x+a*sqrt(x-d);
Writeln(‘hisoblash 2-formula bo”yicha bajarildi ‘,
a,c,d,x,y);
end;
readln;
end.
Bu dasturda shartli operatorning to‘liq konstruksiyasidan foydalanildi, yani
If then
begin
…
end
else
begin
…
end; .
Bunday holatda shartsiz o‘tish operatoridan foydalanishga zarurat bo‘lmaydi.
Masalaning algoritmi bilan dasturi bir-biriga aynan adekvat bo‘lishi zarur.
Hisoblash ikkita tarmoq bo‘yicha amalga oshiriladi:
“HA” tarmog‘i – 1 , 2, 3, 6 bloklar ketma-ketligidir;
“YO‘Q” tarmog‘i - 1 , 2, 3, 4, 5, 6 bloklar ketma-ketligidir.oll
3. To‘liqmas shartli tarmoqlanish.
Misol:
.
,
)
(
,
,
2
c
x
agar
c
x
b
a
d
c
agar
d
c
b
ax
y
Bu erda 4 xil holat bo‘ladi:
1.
d
c
shart bajariladi,
c
x
shart bajarilmaydi,
d
c
b
ax
y
2
,
k=1
ifoda hisoblanadi;
2.
d
c
shart bajarilmaydi,
c
x
shart bajariladi,
)
(
c
x
b
a
y
,
k=2
ifoda hisoblanadi;
3.
d
c
shart bajariladi,
d
c
b
ax
y
2
,
k=1
ifoda hisoblanadi va
c
x
shart ham bajariladi,
)
(
c
x
b
a
y
,
k=2
ifoda hisoblanadi;
23
4.
d
c
shart bajarilmaydi va
c
x
shart ham bajarilmaydi,
k=0,
hisoblash uchun hech qanday ifoda
yo‘q, ya’ni echim yo‘q. Bu erda
k
– qaysi ifoda hisoblanganligini ko‘rsatuvchi parametr, qo‘shimcha oraliq
o‘zgaruvchi, uning dastlabki qiymati nulga teng, ya’ni
k=0
.
A) klassik variant. Algoritmi. Dasturi
1
2
3
4
5
6
7
8
9
10
11
Program tarmoqlanish_to”liqmas_sh;
Label 5,7,9,11;
Var a,b,c,d,x,y:real;
k:integer;
begin
write(‘a,b,c,d,x=’);
readln(a,b,c,d,x);
k:=0;
if c<>d then goto 7;
5:if x>c then goto 9
if k=0 then writeln(‘Yechim
yoq’);
goto 11;
7:y:=(a*x*x+b)/(c-d); k:=1;
Writeln(a,b,c,d,x,y,k);
goto 5;
9:y:=a*sqrt(b*(x-c)); k=2;
Writeln(a,b,c,d,x,y,k);
11:readln;
End.
Program tarmoqlanish_to”liqmas_shart;
Var a,b,c,d,x,y:real;
k:integer;
Бошлаш
a,b,c,d,x
k=0
d
c
.
1
),
/(
)
(
2
k
d
c
b
ax
y
a,b,c,d,x,y,k
c
x
0
k
Ечим йўқ
.
2
,
)
(
k
c
x
b
a
y
a,b,c,d,x,y,k
Тамом
+
+
+
a,b,c,d,x
c ≠ d
x > c
“Ечим йўк”
.
1
),
/(
)
(
2
k
d
c
b
ax
y
.
2
,
)
(
k
c
x
b
a
y
a,b,c,d,x,y,k
k=0
k=0
a,b,c,d,x,y,k
Бошлаш
+
+
+
24
begin
write(‘a,b,c,d,x=’);
readln(a,b,c,d,x);
k:=0;
if c<>d then begin
y:=(a*x*x+b)/(c-d);
k:=1;
Writeln(a,b,c,d,x,y,k);
end;
if x>c then begin
y:=a*sqrt(b*(x-c));
k=2;
Writeln(a,b,c,d,x,y,k);
end;
if k=0 then writeln(‘Yechim yoq’);
readln;
End.
2-
3-
LABORATORIYA ISHI. MATNNI QIDIRISH VA ALMASHTIRISH. AVTOMATN
(AVTOTEKST) ELEMENTLARINI YARATISH
Ishdan maqsad:
Talabalarga Microsoft Word dasturida matnni qidirish va almashtirish. avtomatn
(avtotekst) elementlarini yaratishni o`rgatish
.
Talabalarga Microsoft Word dasturida jadvallar yaratish va
ular bilan ishlashni o`rgatish
.
Talabalarga ms wordda grafik obyektlarni hosil qilish va tahrirlashni
o`rgatish
.
Talabalarga ms wordda formulalar bilan ishlashni o`rgatish
.
Kerakli jihozlar
: kompyuter, MS Word dasturi.
Masalaning quyilishi:
1.
Microsoft Word 2010 dasturi oynasi bilan tanishish.
2.
Microsoft Word 2010 dasturida sahifalar parametri va kolontitullar bilan ishlash.
3.
Microsoft Word 2010 dasturida jadval obyekti va uni formatlash masalalarini o`rganish.
4.
Microsoft Word 2010 matn tarkibida formulalarni shakllantirish.
5.
Satrlararo va simvollararo intervalni o`rnatish.
6.
Hujjatga avtomatik mundarija o’rnatish.
7.
Hujjatga avtomatik snoska izoh o’rnatish.
8.
Microsoft Word 2010 hujjatida jadval tashkil etish
9.
Microsoft Word 2010 hujjati uchun Word protsessori imkoniyatlaridan foydalanijadvalni
tahrirlash.
10.
Microsoft Word 2010 matn fragmenti uchun Найти, Заменить va Перейти buyruqlarini
ishlatish.
11.
Microsoft Word 2010 dasturida matematik formulalar bilan ishlash
12.
Microsoft Word 2010 dasturida sahifalar parametri va kolontitullar bilan ishlash.
13.
Microsoft Word 2010 matn tarkibida formulalarni shakllantirish.
|