911-21 Guruh talabasi Tursunboyev Marufjon
5-Laboratoriya
a)
#include
#include
using namespace std;
double f(double x) {
return 2*x*x*x-3*x-5;
}
int main ()
{
double a,b,c;
do {
cin >>a>>b;
}
while(f(a)*f(b)>0);
cout<<"e=";
double e;
cin>>e;
do {
c=(a+b)/2;
if(f(a)*f(c)<0){
b=c;
}
else a=c;
}
while(b-a>e);
c=(a+b)/2;
cout<}
b)
#include
#include
using namespace std;
double f(double x) {
return 2*x-pow(2,x-1);
}
int main() {
double a, b, c;
do {
cout << "a va b kiriting: ";
cin >> a >> b;
if (f(a) * f(b) > 0) {
cout << "Qiymatlar noto‘g‘ri kiritildi, qayta urinib ko‘ring." << endl;
}
} while (f(a) * f(b) > 0);
cout << "e : ";
double e;
cin >> e;
do {
c = (a + b) / 2;
if (f(a) * f(c) < 0) {
b = c;
} else {
a = c;
}
} while (b - a > e);
cout << "Ildiz: " << c << endl;
return 0;}
Do'stlaringiz bilan baham: |