Guruh talabasi Tursunboyev Marufjon 5-Laboratoriya


Download 39.31 Kb.
Sana18.06.2023
Hajmi39.31 Kb.
#1590295
Bog'liq
5 chi lab Algoritm

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;}

Download 39.31 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling