6-amaliy mashg’ulot
C++ da quyidagi ifodalarning hisoblash dasturi tuzilsin.
2. Dastur kodi: #include #include using namespace std ;
int factr(int a ) {
int d = 1 ;
if (a == 1 or a == 0) {
return d ;
} else if (a < 0) {
return -1 ;
} else {
for (int i = 2 ; i <= a ; i++) {
d*= i ;
}
}
return d ;
}
double z1(float a ,float b , float x) {
double yechim = a * a * b * x - x * a * b * b ;
return yechim ;
}
double z2 ( float x , float y) {
double yechim = pow(x ,3) / factr(3) + (4*x*x*pow(y ,3)) / factr(2) ;
}
double z3 (float x , float y) {
double yechim = x * y * pow(tan(abs(x-4)) , 7) ;
}
int main() {
double x = 4.75 , a , b ,y ;
cout << "y: " ; cin >> y ;
a = pow(x*x + y*y*y*y * (pow(cos(x),2) + pow(sin(y),2)) ,0.25) ;
b = pow(x*x - pow(log(y+5*x)/log(4) , 5), (1/7)) ;
if (a >b) {
cout << z1(a , b, x) ;
} else if (a ==b) {
cout << z2(x ,y ) ;
}
else {
cout << z3(x , y) ;
}
return 0 ;
}
Dastur natijasi:
4.1 dastur kodi: #include #include using namespace std ;
float satr(int n) {
return 1 + n * n ;
}
float maxraj(int n) {
return 1 + n*n*n ;
}
int ishora (int n ) {
return pow(-1 , n) ;
}
int main() {
double d = 1 ;
for (int n = 1 ; n <= 20 ; n++) {
d*= ishora(n) * satr(n) / maxraj(n) ;
}
cout << d ;
}
4.2 dastur kodi: #include #include using namespace std ;
const float e = 2.71 ;
float satr(int m ) {
return m;
}
float maxraj(int m , int i) {
return pow(m*m + pow(e , i + 13) , 0.25);
}
int main() {
double d = 0 ;
for (int n = 10 ; n >= 6 ; n--) {
d+= satr(n ) / maxraj(n ,2) ;
}
cout << d ;
}
Dastur natijasi:
4.3 dastur kodi: #include #include
using namespace std ;
const float e = 2.71 ;
float satr(int m , int r ) {
return m*m*m - r*r + 20;
}
float maxraj(int m , int r) {
return pow( abs(m-r) + m, r);
}
int main() {
double d = 1 ;
for (int n = 1 ; n <= 11 ; n++) {
for (int r = 2 ; r<=16 ; r++) {
d*= satr(n, r) * maxraj(n, r) ;
}
}
cout << d ;
}