Dastur kodi: Dastur natijasi: Dastur blok sxemasi


Download 0.49 Mb.
Sana19.01.2023
Hajmi0.49 Mb.
#1100352
Bog'liq
BOZOROV.B


O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI SAMARQAND FILIALI


“KOMPYUTER INJINIRINGI” FAKULTETI
“AXBOROT TEXNOLOGIYALARI” KAFEDRASI
“Algoritmlarni loyihalash” fanidan
1-HAFTA LABORATORIYA ISHI
(2-kurslar uchun)

Fan o‘qituvchisi:Karimov Marat
Fan o’quvchisi:Bozorov.B

S a m a r q a n d _ 2022


Masala sharti.
S=summa 1/i ni hisoblash dastur i tuzilsin 1/(1+n)-1/n <0.0001 bo’lganda.
#include
#include
using namespace std;
double summa(double i)
{
return 1/i;
}
int main()
{
double n,Z=0;
cout<<"n= ";
cin>>n;
if(1/(n+1)-1/(n)<0.001)
{
for(double j=1;j {
Z+=summa(j);
}
}
cout<<"Z= "<}


Dastur kodi:


Dastur natijasi:





Dastur blok sxemasi.



Boshlash








1 / i



n



1/(n+1)-1/n<0.001








j=1,n


Z+=summa(j);







Z



Tamom

2. #include
#include
using namespace std;
void matrix_print(int a, int m, int n)
{

for (int i = 0; i < m; i++)


{
for (int j = 0; j < n; j++)
{
cout << a[i][j] << "\t";
}
cout << "\n";
}
}
void matrix_input (int **a, int m, int n)
{
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
cin >> a[i][j];
}
void matrix_delete (int **a, int m)
{

for (int i = 0; i < m; i++)


delete []a[i];

delete []a;


}

int create_matrix(int m, int n)


{
int **ptr;

ptr = new int *[m];


for (int i = 0; i < m; i++)

ptr[i] = new int [n];


return ptr;
}
int main()
{
int m, n, **a, **b, **c;
cout << "A matritsa satrlar sonini kiriting \nm="; cin >> m;
cout << "A matritsa ustunlar sonini kiriting \nn="; cin >> n;
a = create_matrix(m, n);
b = create_matrix(m, n);
c = create_matrix(m, n);
cout << "A massiv elementlarini kiriting \n";
matrix_input(a, m, n);
cout << "B massiv elementlarini kiriting \n";
matrix_input(b, m, n);
cout << "Kiritilgan A matritsa\n";
matrix_print(a, m, n);
cout << "Kiritilgan B matritsa\n";
matrix_print(b, m, n);

for (int i = 0; i < m; i++)


for (int j = 0; j < n; j++)
c[i][j] = 0;

for (int i = 0; i < m; i++) {


for (int j = 0; j < n; j++) {
c[i][j] = a[i][j] + b[i][j];
}
}
cout << "Natija C matritsa\n";
matrix_print(c, m, n);
matrix_delete(a, m);
matrix_delete(b, n);
matrix_delete(c, m);
return 0;
system ("pause");
}

Download 0.49 Mb.

Do'stlaringiz bilan baham:




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