Muhammad Al xorazmiy nomidagi tatu ning 313-guruh talabasi


Download 14.87 Kb.
Sana18.06.2023
Hajmi14.87 Kb.
#1559411
Bog'liq
dasturlash5


Muhammad Al xorazmiy nomidagi


TATU ning 313-guruh talabasi
Ibragimov Uzoqmurodning
Dasturlash 2 fanidan 3-topshirig’I

Fan o’tuvchisi: Dauletov Adilbek



  1. Complex sinfidan foydalanib, ikkita kompleks sonlarni qo’shib, yangi kompleks son hosil qiling va shu kompleks sonning haqiqiy qismini aniqlang

#include


#include
using namespace std;

complex complex_addition(complex z1, complex z2) {


double real_part = z1.real() + z2.real();
double imaginary_part = z1.imag() + z2.imag();
complex result(real_part, imaginary_part);
return result;
}

int main() {


complex z1(2, 3);
complex z2(-4, 2);
complex result = complex_addition(z1, z2);
cout << result << endl; // (-2,5)
return 0;
}



Valarray sinfidan foydalanib,massiv elementlari modulini toping.


#include


#include
#include
using namespace std;

int main() {


valarray arr = {1.2, -3.4, 5.6, -7.8};
valarray mod_arr = abs(arr);
for (double val : mod_arr) {
cout << val << " ";
}
cout << endl;
return 0;
}



Download 14.87 Kb.

Do'stlaringiz bilan baham:




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