|
O‘zbekiston respublikаsi raqamli texnologiyalаr vаzirligi muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti samarqand filialiBog'liq Algoritmlarni loyihalash
2-topshiriq.
Butun sonlardan iborat N*N o’lchamli kvadrat matritsa berilgan. Bu
matritsani asosiy dioganali asosida transponerlangan holatda chiqaring?
#include
#include
using namespace std;
int main(){
int n;
double a [100][100];
cout <<"Matritsaning tomonini kiriting ";
cin >> n;
for(int i = 0; i < n; i ++)
for(int j = 0; j < n; j ++) cin >> a[i][j];
cout << "Transponerlangan matritsaning umumiy natijasi "<< endl;
for(int i = 0; i < n; i ++){
for(int j = 0; j < n; j ++) cout << a[j][i] << " ";
cout << endl;
}}
5
3 4 9 1 2
8 2 0 5 1
4 7 4 8 7
7 1 3 3 8
5 6 3 7 0
3
8
4
7
5
4 2 7 1 6
9 0 4 3 3
1 5 8 3 7
2 1 7 8 0
3-topshiriq.
Butun sonlardan iborat NxM o’lchamli matritsa berilgan. Matritsani ustun
elеmеntlari yigindisidan vеktоr хоsil qilinsin.Matritsaningeng katta va eng
kichik elеmnti aniqlansin
.
4 7
16 -34 156 49 250 39 -51
-84 38 30 78 59 49 -58
64 -76 65 -17 24 -89 59
-36 55 33 61 74 87 -93
72 -51 28 -73 93 -8 41
93 -93
#include
#include
using namespace std;
int main(){
int n, m;
double a [100][100];
cout << "Matritsaning satrlar sonini kiriting ";
cin >> n;
cout << "Matritsaning ustunlar sonini kiriting ";
cin >> m;
for(int i = 0; i < n; i ++)
for(int j = 0; j < m; j ++)
cin >> a[i][j];
int b[100] = {0};
int min = a[0][0];
int max = a[0][0];
for(int i = 0; i < n; i ++)
for(int j = 0; j < m; j ++)
{
if(min > a[i][j]) min = a[i][j];
if(max < a[i][j]) max = a[i][j];
}
for(int i = 0; i < m; i ++)
for(int j = 0; j < n; j ++){
b[i] += a[j][i];
}
cout << "Matritsani ustun elеmеntlari yigindisi " << endl;
for(int i = 0; i < n; i ++)
cout << i + 1 << "ustunning yig'indisi " << b[i] << "ga teng \n";
cout << "Matritsaning eng katta elementi " << max;
cout << endl;
cout << "Matritsaning eng kichik elementi " << min;
}
4-topshiriq.
Quyidagi transsendent tenglamani oraliqni teng ikkiga bo’lish va oddiy
iteratsiya usuli yordamida yechimini aniqlovchi dastur tuzing: 2x
3
-x-5=0
#include
#include
using namespace std;
double funksiya(double x) {
return 2 * pow(x, 3) - x - 5;}
double tekshirish(double x) {
return 6 * pow(x, 2) - 1;}
int main() {
double x0 = 0;
double jj = 0.0001;
int ii = 1000;
double x = x0;
for (int i = 0; i < ii; ++i) {
double funksiya1 = funksiya(x);
double funksiya3 = tekshirish(x);
double y = x - funksiya1 / funksiya3;
double error = abs(y - x);
x = y;
if (error < jj) {
cout << "Yechim: " << x << endl;
break;
} } return 0;}
5-topshiriq.
Quyidagi transsendent tenglamani Nyuton va Vatarlar usuli yordamida
yechimini aniqlovchi dastur tuzing: 2x
3
-2x
2
+3x+1=0
#include
#include
using namespace std;
double f(double x) {
return 2 * pow(x, 3) - 2 * pow(x, 2) + 3 * x + 1;
}
double funksiya(double x) {
return 6 * pow(x, 2) - 4 * x + 3;
}
int main() {
double x0 = 0;
double ii = 0.0001;
int max = 1000;
double x = x0;
for (int i = 0; i < max; ++i) {
double q = f(x);
double yy = funksiya(x);
double xx = x - q / yy;
double error = abs(xx - x);
x = xx;
if (error < ii) {
cout << "Yechim: " << x << endl;
break;
} }
return 0;
}
|
|
Bosh sahifa
Aloqalar
Bosh sahifa
O‘zbekiston respublikаsi raqamli texnologiyalаr vаzirligi muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti samarqand filiali
|