Paskal da chiziqli algoritmlarga doir dasturlar tuzish.
1.1-masala. A va B ikkita haqiqy sonlar berilgan. Ularning yig`indisi va ko’paytmasini hisoblash dasturini tuzing
Dastur matni
program yg`indi;
var a,b,s,p:real;
begin
write('a='); read(a);
write('b='); read(b);
s:=a+b;
p:=a*b;
write('s=',s);
write('p=',p);
end.
1.2-masala. Ikkita musbat son berilgan, bu sonlarning o’rta arifmetik va o’rta geometrik qiymatlarini hisoblash dasturini tuzing.
Dastur matni
program misol 2;
var a,b,s,p:real;
begin
write('a='); read(a);;
write('b='); read(b);
s:=(a+b)/2;
p:=sqrt(a*b);
write('s=',s);
write('p=',p);
end.
1.3-masala. Tomonlari a va b ga teng bo’lgan to’g’ri to’rtburchakning yuzi va peremetrini hisoblash dasturini tuzing.
Dastur matni
program misol 3;
var
a,b,s,p: real;
begin
write('a='); read(a);
write('b='); read(b);
s:=a*b; p:=2*(a+b);
write('s=',s);
write('p=',p);
end.
1.4-masala. Teng tomonli uchburchakning tomoni A ga teng. Uchburchakning yuzini topish dasturini tuzing.
Dastur matni
program misol 4;
var a,s:real;
begin
write('a='); read(a);
S:=(sqrt(3))*a*a/4;
write('S=',S);
end.
1.5-masala. Koordinatalari x1,y1 va x2, y2 ga teng bo’lgan nuqtalar orasidagi masofani hisoblash dasturini tuzing.
Dastur matni
program misol 5;
var x1,x2,y1,y2,d:real;
begin
write('x1='); read(x1);
write('x2='); read(x2);
write('y1='); read(y1);
write('y2='); read(y2);
d:=sqrt(sqr(x2-x1)+sqr(y2-y1));
write('d=',d);
end.
1.6-masala. Birinchi hadi a1, ayirmasi d, hadlari soni n ga teng arifmetik progressiyaning hadlarining yig’indisini hisoblash dasturini tuzing.
Dastur matni
program misol 6;
var a1,d,n,S: real;
begin
write('a1='); read(a1);
write('d='); read(d);
write('n='); read(n);
S:=(2*a1+d*(n-1))/2*n;
write('S=',S);
end.
1.7-masala. Birinchi hadi b, maxraji q va hadlari soni n ga teng geometrik progressiyaning hadlarining yig’indisi S ni hisoblash dasturini tuzing.
Dastur matni
program misol 7;
var B,N,Q,S:real;
begin
write('B='); read(B);
write('Q='); read(Q);
write('B='); read(B);
S:=(B*(1-exp(N*ln(Q))))/(1-Q);
write('S=',S);
end.
1.8-masala. Berilgan sonning butun qismini aniqlang.
Dastur matni
program misol 8;
var a,b,s:real;
begin
write('a='); read(a);
write('b='); read(b);
s:=a div b;
write('s=',s);
end.
1.9-masala. Bir tomoni va unga yopishgan ikkita burchagi berilgan uchburchakning uchinchi burchagi va qolgan ikki tomonini aniqlang.
Dastur matni
program misol 9;
var a,ab,bb,b,c,cb:real;
begin
write('a='); read(a);
write('ab='); read(ab);
write('cb='); read(cb);
cb:=pi-ab*pi/180-bb*pi/180;
b:=a*sin(bb)/sin(ab);
c:=a*sin(cb)/sin(ab);
write('cb=',cb);
write('b=',b);
write('c=',c);
end.
Do'stlaringiz bilan baham: |