Uploaded by abbos7054

XUDOYNAZAROV SHOKIR mustaqil ish

advertisement
O’ZBEKISTON RESPUBLIKASI AXBOROT
TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI
RIVOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIY
NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI
UNVERSITETI
“Algoritim va loyihalash” fani bo’yicha
Bajardi: Xudoynazarov Shokir
Tashkent 2024
#include<bits/stdc++.h>
using namespace std;
int main() {
int n = 10, k = 0;
float a = 0, b = 1, e, x, h, s0 = 1000000, s1 = 0;
cout << "Integral 'To`g`ri to`rtburchak' usulida hisoblanadi " << endl;
cout << "Qanday aniqlikda hisoblansin : ";
cin >> e;
while (1) {
h = (b - a) / n;
for (int i = 0; i <= n; i++) {
x = a + i * h;
s1 += sin(x * x + x + 1) / (pow(x,3) + 5 * x +1);
}
s1 *= h;
if (fabs(s1 - s0) < e) {
cout << " Natija : " << s1 << endl;
cout << " Qadamlar soni : " << k;
break;
} else {
s0 = s1;
s1 = 0;
k++;
n *= 2;
}
}
}
#include<bits/stdc++.h>
using namespace std;
int main() {
int n = 10, k = 0;
float a = 0, b = 1, e, x, h, s0 = 1000000, s1 = 0;
cout << "Integral 'Trapetsiya' usulida hisoblanadi " << endl;
cout << "Qanday aniqlikda hisoblansin : ";
cin >> e;
while (1) {
h = (b - a) / n;
for (int i = 0; i <= n; i++) {
x = a + i * h;
if (i == 0 or i == n)
s1 += sin(x * x + x + 1) / (pow(x,3) + 5 * x +1);
else
s1 += 2 * sin(x * x + x + 1) / (pow(x,3) + 5 * x +1);
}
s1 *= h / 2;
if (fabs(s1 - s0) < e) {
cout << "Natija : " << s1;
cout << " \n Qadamlar soni : " << k;
break;
} else {
s0 = s1;
s1 = 0;
n *= 2;
k++;
}
}
}
#include<bits/stdc++.h>
using namespace std;
int main() {
int n = 10, k = 0;
float a = 0, b = 1, e, x, h, s0 = 1000000, s1 = 0;
cout << "Integral 'Simpson' usulida hisoblanadi " << endl;
cout << "Qanday aniqlikda hisoblansin : ";
cin >> e;
while (1) {
h = (b - a) / n;
for (int i = 0; i <= n; i++) {
x = a + i * h;
if (i == 0 or i == n)
s1 += sin(x * x + x + 1) / (pow(x,3) + 5 * x +1);
else if (i % 2 == 0)
s1 += 4 * sin(x * x + x + 1) / (pow(x,3) + 5 * x +1);
else
s1 += 2 * sin(x * x + x + 1) / (pow(x,3) + 5 * x +1);
}
s1 *= h / 3;
if (fabs(s1 - s0) < e) {
cout << "Natija : " << s1 << endl;
cout << " Qadamlar soni : " << k;
break;
} else {
s0 = s1;
s1 = 0;
n *= 2;
k++;
}
}
}
#include <bits/stdc++.h>
using namespace std;
float math_func(float x) {
return x * x + 4 * sin(x);
}
int main() {
float a, b, e, c;
cout << "Oraliqni kiriting = >[a ; b] \na=";
cin >> a;
cout << "b=";
cin >> b;
cout << "Aniqlikni kiritin E=";
cin >> e;
Line:
c = a - math_func(a) * (b - a) / (math_func(b) - math_func(a));
if (abs(math_func(c)) <= e) {
cout << "Javob:" << c << endl;
} else {
if (math_func(a) * math_func(b) < 0) {
b = c;
goto Line;
} else {
a = c;
goto Line;
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
float math_func(float x){
return pow(x,3) - 0.1 * pow(x,2) + 0.4 * x + 1.2;
}
int main(){
float a,b,e,c;
cout << "Oraliqni kiriting = >[a ; b] \na=";
cin >> a;
cout << "b=";
cin >> b;
cout << "Aniqlikni kiritin E=";
cin >> e;
Line:
c = a - math_func(a) * (b-a)/(math_func(b)-math_func(a));
if(abs(math_func(c))<= e){
cout << "Javob:" << c << endl;
} else {
if(math_func(a)*math_func(b) < 0){
b =c;
goto Line;
} else {
a = c;
goto Line;
}
}
return 0;
}
Download