answer (Компл. числ. Корень, под которым -15+8i)

#include "stdafx.h"//del #include <iostream> #include <cmath> #include <complex> using namespace std; complex<double> func() { complex<double > result(0, 0); complex<double > eight(8, 0); complex<double > fifteen(15, 0); complex<double > I(0, 1); result = sqrt(-fifteen + eight*I); return result; } int main() { complex<double> result(0, 0); result = func(); if (result.imag() == 0) cout << "answer= " << result.real() << endl; else if (result.imag() == 1) cout << "answer= " << result.real() << " + i" << endl; else cout << "answer= " << result.real() << " + " << result.imag() << "i" << endl; return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.