Blok sxema
n! ni hisoblaydigan funksiya tuzamiz. n!=1•2•3•…•n;
K=Fact(n)
Asosiy dasturda
orqali qism dasturga(fumsiyaga) murojaat qilamiz.
Misol 1:
F(x, y) =
Z=F(a, b)+F(a/b, F(a2, b2))
a va b sonlari berilgan.
F(x, y)
Z ning qiymatini toppish kerak.
Blok sxemasi:
x+y<0
R=
R=
Tamom
F=R
Tamom
Z
Z=F(a,b)+F(a/b,F(a2+b2))
Boshlash
a,b
#include
#include
#include
using namespace std;
double F(double x, double y) {
double R;
if (x+y < 0)
R = x*x + y*y;
else
R = sqrt(x+y);
return R;
}
int main() {
double a, b;
cin>>a>>b;
double Z = F(a, b)+F(a/b, F(a*a, b*b));
printf("%.20f", Z);
}
Misol2
To’rtburchakning tamonlari va bitta diagonali berilgan. Uning yuzasini topuvchi dastur tuzing.
Yechimi:
To’rtburchak yuzasi diagonal ajratgan tamonlari (a, b, e) va (c, d, e) bo’lgan ikkita uchburchaklar yuzalari yi’gindisiga teng.
Uchburchak yuzasini ikki marta hisoblashga lozim. Ikki marta bir xil amalni yozmaslik uchun uchburchak yuzasini topadigan funksiya tuzamiz va unga ikki marta murojaaat qilamiz.
#include
#include
#include
using namespace std;
double surface_traingle(int a, int b, int c) {
double p = (a+b+c) / 2.0;
double s = sqrt(p*(p-a)*(p-b)*(p-c));
return s;
}
int main() {
int a, b, c, d, e;
cin>>a>>b>>c>>d>>e;
double s = surface_traingle(a, b, e) + surface_traingle(c, d, e);
printf("%.10f", s);
}
0>
Dostları ilə paylaş: |