Bekchanov Bekzod 8-Amaliy ish. Mavzu: Sonli sinflar va ular bilan ishlash. Complex sonlar, (vallaray, slice, gslice va h k.) Masala sharti


Download 31.23 Kb.
Sana21.06.2023
Hajmi31.23 Kb.
#1645819
Bog'liq
8-amaliy ish



942-22 Bekchanov Bekzod
8-Amaliy ish.
Mavzu: Sonli sinflar va ular bilan ishlash. Complex sonlar, (vallaray, slice, gslice va h.k.)

Masala sharti:
Complex sinfidan foydalanib, ikkita kompleks sonlarni ko’paytiring.
Dastur kodi:
#include
using namespace std;

class Complex {


private:
double real;
double img;

public:
Complex(double r = 0, double i = 0) {


real = r;
img = i;
}

Complex operator*(Complex const& obj) {


Complex res;
res.real = real * obj.real - img * obj.img;
res.img = real * obj.img + img * obj.real;
return res;
}

void print() {


cout << real << " + i" << img << endl;
}
};

int main() {


Complex num1(4, 5);
Complex num2(6, 7);

Complex result = num1 * num2;


cout << "Ko'paytirilgan son: ";
result.print();
return 0;
}
Natija:



Download 31.23 Kb.

Do'stlaringiz bilan baham:




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