Реализация класса для работы с комплексными числами
cout << "Vvedite chislo ctepeni korny:" << endl;
cin >> m;
cout << "Vvedite nomer korny:" << endl;
cin >> k;
double r=sqrt(a.re*a.re+a.im*a.im);
21
double rn=pow(2,r);double f1=(m*a.re/rn+2*3,14*k)/m;
double f2=(m*a.im/rn+2*3.14*k)/m;
cout << "Trigonom form vyshislenie korny a:" << endl;
cout << rn << "(cos(" << f1 << ") + isin(" << f2 << "))" << endl;
Complex t(m,k);
return t;
}
Complex operator == (Complex &a,Complex &b){
double r=sqrt(a.re*a.re+a.im*a.im);
double f2=a.re/r;
cout << "Eksponenta a:" << endl;
cout << r << "e^(i*" << f2 << ")" << endl;
Complex t(r,f2);
return t;
}
void Complex::ShowComplex(){
cout << "Vvedite chislo" <<endl;
cin >> re;
cin >> im;
cout << "Arif. forma: " << re << " + " << im << "i" << endl;
double z=sqrt(re*re+im*im);
cout << "Modul' shisla:" << z << endl;
cout << "Trigonom form" << endl;
double f=re/z;
double f1=im/z;
cout << z << "(cos(" << f << ") + isin(" << f1 << "))" << endl;
}
#include "stdafx.h"
#include "Complex.h"
#include "conio.h"
#include "iostream"
#include "math.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Complex a;
Complex b;
Complex ob;
a.ShowComplex();
b.ShowComplex();
a+b;
a-b;
a*b;
a/b;
a&b;
a&&b;
a==b;
getch();
return 0;
}
28
Приложение Б (Справочное)
Результаты тестирования


28


28


28