Loading [MathJax]/extensions/tex2jax.js

Как тестируются задачи

Вам нужно написать программу, которая содержит только требуемую функцию (можно несколько функций, если одна функция будет вызывать другую). Программа не должна содержать никакого кода вне функций.

В тестирующей системе после вашей программы будет добавлен следующий код, после чего решение будет проверено на тестах.

Задание A

int main()
{
    { complex <double> z1; {cout << """complex <double> z1"": " ; complex <double> z1; cout << endl;}; {cout << """cout << sizeof(z1.re())"": " ; cout << sizeof(z1.re()); cout << endl;}; {cout << """cout << sizeof(z1.im())"": " ; cout << sizeof(z1.im()); cout << endl;}; {cout << """z1 = complex<double>(1.5, 2.5)"": " ; z1 = complex<double>(1.5, 2.5); cout << endl;}; {cout << """cout << z1.re()"": " ; cout << z1.re(); cout << endl;}; {cout << """cout << z1.im()"": " ; cout << z1.im(); cout << endl;}; {cout << """z1 = complex<double>(3.5)"": " ; z1 = complex<double>(3.5); cout << endl;}; {cout << """cout << z1.re()"": " ; cout << z1.re(); cout << endl;}; {cout << """cout << z1.im()"": " ; cout << z1.im(); cout << endl;}; {cout << """z1 = complex<double>()"": " ; z1 = complex<double>(); cout << endl;}; {cout << """cout << z1.re()"": " ; cout << z1.re(); cout << endl;}; {cout << """cout << z1.im()"": " ; cout << z1.im(); cout << endl;}; cout << endl; };
    { complex <long double> z2; {cout << """complex <long double> z2"": " ; complex <long double> z2; cout << endl;}; {cout << """cout << sizeof(z2.re())"": " ; cout << sizeof(z2.re()); cout << endl;}; {cout << """cout << sizeof(z2.im())"": " ; cout << sizeof(z2.im()); cout << endl;}; {cout << """z2 = complex<long double>(1.5, 2.5)"": " ; z2 = complex<long double>(1.5, 2.5); cout << endl;}; {cout << """cout << z2.re()"": " ; cout << z2.re(); cout << endl;}; {cout << """cout << z2.im()"": " ; cout << z2.im(); cout << endl;}; {cout << """z2 = complex<long double>(3.5)"": " ; z2 = complex<long double>(3.5); cout << endl;}; {cout << """cout << z2.re()"": " ; cout << z2.re(); cout << endl;}; {cout << """cout << z2.im()"": " ; cout << z2.im(); cout << endl;}; {cout << """z2 = complex<long double>()"": " ; z2 = complex<long double>(); cout << endl;}; {cout << """cout << z2.re()"": " ; cout << z2.re(); cout << endl;}; {cout << """cout << z2.im()"": " ; cout << z2.im(); cout << endl;}; cout << endl; };
    { complex <float> z3; {cout << """complex <float> z3"": " ; complex <float> z3; cout << endl;}; {cout << """cout << sizeof(z3.re())"": " ; cout << sizeof(z3.re()); cout << endl;}; {cout << """cout << sizeof(z3.im())"": " ; cout << sizeof(z3.im()); cout << endl;}; {cout << """z3 = complex<float>(1.5, 2.5)"": " ; z3 = complex<float>(1.5, 2.5); cout << endl;}; {cout << """cout << z3.re()"": " ; cout << z3.re(); cout << endl;}; {cout << """cout << z3.im()"": " ; cout << z3.im(); cout << endl;}; {cout << """z3 = complex<float>(3.5)"": " ; z3 = complex<float>(3.5); cout << endl;}; {cout << """cout << z3.re()"": " ; cout << z3.re(); cout << endl;}; {cout << """cout << z3.im()"": " ; cout << z3.im(); cout << endl;}; {cout << """z3 = complex<float>()"": " ; z3 = complex<float>(); cout << endl;}; {cout << """cout << z3.re()"": " ; cout << z3.re(); cout << endl;}; {cout << """cout << z3.im()"": " ; cout << z3.im(); cout << endl;}; cout << endl; };
    { complex <int> z4; {cout << """complex <int> z4"": " ; complex <int> z4; cout << endl;}; {cout << """cout << sizeof(z4.re())"": " ; cout << sizeof(z4.re()); cout << endl;}; {cout << """cout << sizeof(z4.im())"": " ; cout << sizeof(z4.im()); cout << endl;}; {cout << """z4 = complex<int>(1.5, 2.5)"": " ; z4 = complex<int>(1.5, 2.5); cout << endl;}; {cout << """cout << z4.re()"": " ; cout << z4.re(); cout << endl;}; {cout << """cout << z4.im()"": " ; cout << z4.im(); cout << endl;}; {cout << """z4 = complex<int>(3.5)"": " ; z4 = complex<int>(3.5); cout << endl;}; {cout << """cout << z4.re()"": " ; cout << z4.re(); cout << endl;}; {cout << """cout << z4.im()"": " ; cout << z4.im(); cout << endl;}; {cout << """z4 = complex<int>()"": " ; z4 = complex<int>(); cout << endl;}; {cout << """cout << z4.re()"": " ; cout << z4.re(); cout << endl;}; {cout << """cout << z4.im()"": " ; cout << z4.im(); cout << endl;}; cout << endl; };
    { complex <long> z5; {cout << """complex <long> z5"": " ; complex <long> z5; cout << endl;}; {cout << """cout << sizeof(z5.re())"": " ; cout << sizeof(z5.re()); cout << endl;}; {cout << """cout << sizeof(z5.im())"": " ; cout << sizeof(z5.im()); cout << endl;}; {cout << """z5 = complex<long>(1.5, 2.5)"": " ; z5 = complex<long>(1.5, 2.5); cout << endl;}; {cout << """cout << z5.re()"": " ; cout << z5.re(); cout << endl;}; {cout << """cout << z5.im()"": " ; cout << z5.im(); cout << endl;}; {cout << """z5 = complex<long>(3.5)"": " ; z5 = complex<long>(3.5); cout << endl;}; {cout << """cout << z5.re()"": " ; cout << z5.re(); cout << endl;}; {cout << """cout << z5.im()"": " ; cout << z5.im(); cout << endl;}; {cout << """z5 = complex<long>()"": " ; z5 = complex<long>(); cout << endl;}; {cout << """cout << z5.re()"": " ; cout << z5.re(); cout << endl;}; {cout << """cout << z5.im()"": " ; cout << z5.im(); cout << endl;}; cout << endl; };
    { complex <long long> z6; {cout << """complex <long long> z6"": " ; complex <long long> z6; cout << endl;}; {cout << """cout << sizeof(z6.re())"": " ; cout << sizeof(z6.re()); cout << endl;}; {cout << """cout << sizeof(z6.im())"": " ; cout << sizeof(z6.im()); cout << endl;}; {cout << """z6 = complex<long long>(1.5, 2.5)"": " ; z6 = complex<long long>(1.5, 2.5); cout << endl;}; {cout << """cout << z6.re()"": " ; cout << z6.re(); cout << endl;}; {cout << """cout << z6.im()"": " ; cout << z6.im(); cout << endl;}; {cout << """z6 = complex<long long>(3.5)"": " ; z6 = complex<long long>(3.5); cout << endl;}; {cout << """cout << z6.re()"": " ; cout << z6.re(); cout << endl;}; {cout << """cout << z6.im()"": " ; cout << z6.im(); cout << endl;}; {cout << """z6 = complex<long long>()"": " ; z6 = complex<long long>(); cout << endl;}; {cout << """cout << z6.re()"": " ; cout << z6.re(); cout << endl;}; {cout << """cout << z6.im()"": " ; cout << z6.im(); cout << endl;}; cout << endl; };
    return 0;
}

Задание B

int main()
{
    {cout << """cout << sizeof(5_i)"": " ; cout << sizeof(5_i); cout << endl;};
    {cout << """cout << 5_i .re()"": " ; cout << 5_i .re(); cout << endl;};
    {cout << """cout << 5_i .im()"": " ; cout << 5_i .im(); cout << endl;};
    cout << endl;
    {cout << """cout << sizeof(6.5_i)"": " ; cout << sizeof(6.5_i); cout << endl;};
    {cout << """cout << 6.5_i .re()"": " ; cout << 6.5_i .re(); cout << endl;};
    {cout << """cout << 6.5_i .im()"": " ; cout << 6.5_i .im(); cout << endl;};
    cout << endl;
    {cout << """cout << sizeof(57_if)"": " ; cout << sizeof(57_if); cout << endl;};
    {cout << """cout << 7_if .re()"": " ; cout << 7_if .re(); cout << endl;};
    {cout << """cout << 7_if .im()"": " ; cout << 7_if .im(); cout << endl;};
    cout << endl;
    {cout << """cout << sizeof(8.5_if)"": " ; cout << sizeof(8.5_if); cout << endl;};
    {cout << """cout << 8.5_if .re()"": " ; cout << 8.5_if .re(); cout << endl;};
    {cout << """cout << 8.5_if .im()"": " ; cout << 8.5_if .im(); cout << endl;};
    cout << endl;
    {cout << """cout << sizeof(3_il)"": " ; cout << sizeof(3_il); cout << endl;};
    {cout << """cout << 3_il .re()"": " ; cout << 3_il .re(); cout << endl;};
    {cout << """cout << 3_il .im()"": " ; cout << 3_il .im(); cout << endl;};
    cout << endl;
    {cout << """cout << sizeof(5.0_il)"": " ; cout << sizeof(5.0_il); cout << endl;};
    {cout << """cout << 4.5_il .re()"": " ; cout << 4.5_il .re(); cout << endl;};
    {cout << """cout << 4.5_il .im()"": " ; cout << 4.5_il .im(); cout << endl;};
    cout << endl;
    return 0;
}

Задание C

int main()
{
    {cout << """cout << 1_i << endl"": " ; cout << 1_i << endl; cout << endl;};
    {cout << """cout << 1_if << endl"": " ; cout << 1_if << endl; cout << endl;};
    {cout << """cout << 1_il << endl"": " ; cout << 1_il << endl; cout << endl;};
    for (long double x = -2; x <= 2; x += 0.5)
        for (long double y = -2; y <= 2; y += 0.5)
        {
            {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
            {cout << """cout << complex<long double>(x, y)"": " ; cout << complex<long double>(x, y); cout << endl;};
            cout << endl;
        }
    {cout << """cout << complex<long double>(+1e+1000L, +1e+1000L)"": " ; cout << complex<long double>(+1e+1000L, +1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e+1000L, +1e-1000L)"": " ; cout << complex<long double>(+1e+1000L, +1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e+1000L, -1e+1000L)"": " ; cout << complex<long double>(+1e+1000L, -1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e+1000L, -1e-1000L)"": " ; cout << complex<long double>(+1e+1000L, -1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e-1000L, +1e+1000L)"": " ; cout << complex<long double>(+1e-1000L, +1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e-1000L, +1e-1000L)"": " ; cout << complex<long double>(+1e-1000L, +1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e-1000L, -1e+1000L)"": " ; cout << complex<long double>(+1e-1000L, -1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e-1000L, -1e-1000L)"": " ; cout << complex<long double>(+1e-1000L, -1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e+1000L, +1e+1000L)"": " ; cout << complex<long double>(-1e+1000L, +1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e+1000L, +1e-1000L)"": " ; cout << complex<long double>(-1e+1000L, +1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e+1000L, -1e+1000L)"": " ; cout << complex<long double>(-1e+1000L, -1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e+1000L, -1e-1000L)"": " ; cout << complex<long double>(-1e+1000L, -1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e-1000L, +1e+1000L)"": " ; cout << complex<long double>(-1e-1000L, +1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e-1000L, +1e-1000L)"": " ; cout << complex<long double>(-1e-1000L, +1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e-1000L, -1e+1000L)"": " ; cout << complex<long double>(-1e-1000L, -1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(-1e-1000L, -1e-1000L)"": " ; cout << complex<long double>(-1e-1000L, -1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(+1e+1000L, 0)"": " ; cout << complex<long double>(+1e+1000L, 0); cout << endl;};
    {cout << """cout << complex<long double>(+1e-1000L, 0)"": " ; cout << complex<long double>(+1e-1000L, 0); cout << endl;};
    {cout << """cout << complex<long double>(-1e+1000L, 0)"": " ; cout << complex<long double>(-1e+1000L, 0); cout << endl;};
    {cout << """cout << complex<long double>(-1e-1000L, 0)"": " ; cout << complex<long double>(-1e-1000L, 0); cout << endl;};
    {cout << """cout << complex<long double>(0, +1e+1000L)"": " ; cout << complex<long double>(0, +1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(0, +1e-1000L)"": " ; cout << complex<long double>(0, +1e-1000L); cout << endl;};
    {cout << """cout << complex<long double>(0, -1e+1000L)"": " ; cout << complex<long double>(0, -1e+1000L); cout << endl;};
    {cout << """cout << complex<long double>(0, -1e-1000L)"": " ; cout << complex<long double>(0, -1e-1000L); cout << endl;};
    cout << "TESTING CERR" << endl;
    for (long double x = -2; x <= 2; x += 0.5)
        for (long double y = -2; y <= 2; y += 0.5)
        {
            cerr << complex<long double>(x, y) << endl;
        }
    return 0;
}

Задание D

int main()
{
    {cout << """cout << 1_i .conj() << endl"": " ; cout << 1_i .conj() << endl; cout << endl;};
    {cout << """cout << 1_il .conj() << endl"": " ; cout << 1_il .conj() << endl; cout << endl;};
    {cout << """cout << 1_if .conj() << endl"": " ; cout << 1_if .conj() << endl; cout << endl;};
    for (double x = -2; x <= 2; x += 0.5)
        for (double y = -2; y <= 2; y += 0.5)
        {
            complex<double> z;
            {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
            {cout << """z = complex<double>(x, y)"": " ; z = complex<double>(x, y); cout << endl;};
            {cout << """cout << z.conj()"": " ; cout << z.conj(); cout << endl;};
            {cout << """cout << z"": " ; cout << z; cout << endl;};
            cout << endl;
        }
    return 0;
}

Задание E

int main()
{
    {cout << """cout << 1_i + 1_i << endl"": " ; cout << 1_i + 1_i << endl; cout << endl;};
    {cout << """cout << 1.0 + 1_i << endl"": " ; cout << 1.0 + 1_i << endl; cout << endl;};
    {cout << """cout << 1_i + 1.0 << endl"": " ; cout << 1_i + 1.0 << endl; cout << endl;};
    {cout << """cout << 1_if + 1_if << endl"": " ; cout << 1_if + 1_if << endl; cout << endl;};
    {cout << """cout << 1.0F + 1_if << endl"": " ; cout << 1.0F + 1_if << endl; cout << endl;};
    {cout << """cout << 1_if + 1.0F << endl"": " ; cout << 1_if + 1.0F << endl; cout << endl;};
    {cout << """cout << 1e1000_il + 1e1000_il << endl"": " ; cout << 1e1000_il + 1e1000_il << endl; cout << endl;};
    {cout << """cout << 1e1000L + 1e1000_il << endl"": " ; cout << 1e1000L + 1e1000_il << endl; cout << endl;};
    {cout << """cout << 1e1000_il + 1e1000L << endl"": " ; cout << 1e1000_il + 1e1000L << endl; cout << endl;};
    for (double x1 = -2; x1 <= 2; x1 += 0.5)
        for (double y1 = -2; y1 <= 2; y1 += 0.5)
            for (double x2 = -2; x2 <= 2; x2 += 0.5)
            {
                for (double y2 = -2; y2 <= 2; y2 += 0.5)
                {
                    {cout << """cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2"": " ; cout << x1 << " " << y1 << " " << x2 << " " << y2; cout << endl;};
                    {cout << """cout << complex<double>(x1, y1) + complex<double>(x2, y2)"": " ; cout << complex<double>(x1, y1) + complex<double>(x2, y2); cout << endl;};
                    cout << endl;
                }
                {cout << """cout << x1 << \" \" << y1 << \" \" << x2"": " ; cout << x1 << " " << y1 << " " << x2; cout << endl;};
                {cout << """cout << complex<double>(x1, y1) + x2"": " ; cout << complex<double>(x1, y1) + x2; cout << endl;};
                {cout << """cout << x2 + complex<double>(x1, y1)"": " ; cout << x2 + complex<double>(x1, y1); cout << endl;};
                cout << endl;
            }
    return 0;
}

Задание F

int main()
{
    {cout << """cout << 2_i - 1_i << endl"": " ; cout << 2_i - 1_i << endl; cout << endl;};
    {cout << """cout << 2.0 - 1_i << endl"": " ; cout << 2.0 - 1_i << endl; cout << endl;};
    {cout << """cout << 2_i - 1.0 << endl"": " ; cout << 2_i - 1.0 << endl; cout << endl;};
    {cout << """cout << 2_if - 1_if << endl"": " ; cout << 2_if - 1_if << endl; cout << endl;};
    {cout << """cout << 2.0F - 1_if << endl"": " ; cout << 2.0F - 1_if << endl; cout << endl;};
    {cout << """cout << 2_if - 1.0F << endl"": " ; cout << 2_if - 1.0F << endl; cout << endl;};
    {cout << """cout << 2e1000_il - 1e1000_il << endl"": " ; cout << 2e1000_il - 1e1000_il << endl; cout << endl;};
    {cout << """cout << 2e1000L - 1e1000_il << endl"": " ; cout << 2e1000L - 1e1000_il << endl; cout << endl;};
    {cout << """cout << 2e1000_il - 1e1000L << endl"": " ; cout << 2e1000_il - 1e1000L << endl; cout << endl;};
    for (double x1 = -2; x1 <= 2; x1 += 0.5)
        for (double y1 = -2; y1 <= 2; y1 += 0.5)
            for (double x2 = -2; x2 <= 2; x2 += 0.5)
            {
                for (double y2 = -2; y2 <= 2; y2 += 0.5)
                {
                    {cout << """cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2"": " ; cout << x1 << " " << y1 << " " << x2 << " " << y2; cout << endl;};
                    {cout << """cout << complex<double>(x1, y1) - complex<double>(x2, y2)"": " ; cout << complex<double>(x1, y1) - complex<double>(x2, y2); cout << endl;};
                    cout << endl;
                }
                {cout << """cout << x1 << \" \" << y1 << \" \" << x2"": " ; cout << x1 << " " << y1 << " " << x2; cout << endl;};
                {cout << """cout << complex<double>(x1, y1) - x2"": " ; cout << complex<double>(x1, y1) - x2; cout << endl;};
                {cout << """cout << x2 - complex<double>(x1, y1)"": " ; cout << x2 - complex<double>(x1, y1); cout << endl;};
                cout << endl;
            }
    return 0;
}

Задание G

int main()
{
    {cout << """cout << 2_i * 1_i << endl"": " ; cout << 2_i * 1_i << endl; cout << endl;};
    {cout << """cout << 2.0 * 1_i << endl"": " ; cout << 2.0 * 1_i << endl; cout << endl;};
    {cout << """cout << 2_i * 1.0 << endl"": " ; cout << 2_i * 1.0 << endl; cout << endl;};
    {cout << """cout << 2_if * 1_if << endl"": " ; cout << 2_if * 1_if << endl; cout << endl;};
    {cout << """cout << 2.0F * 1_if << endl"": " ; cout << 2.0F * 1_if << endl; cout << endl;};
    {cout << """cout << 2_if * 1.0F << endl"": " ; cout << 2_if * 1.0F << endl; cout << endl;};
    {cout << """cout << 2e1000_il * 1e1000_il << endl"": " ; cout << 2e1000_il * 1e1000_il << endl; cout << endl;};
    {cout << """cout << 2e1000L * 1e1000_il << endl"": " ; cout << 2e1000L * 1e1000_il << endl; cout << endl;};
    {cout << """cout << 2e1000_il * 1e1000L << endl"": " ; cout << 2e1000_il * 1e1000L << endl; cout << endl;};
    for (double x1 = -2; x1 <= 2; x1 += 0.5)
        for (double y1 = -2; y1 <= 2; y1 += 0.5)
            for (double x2 = -2; x2 <= 2; x2 += 0.5)
            {
                for (double y2 = -2; y2 <= 2; y2 += 0.5)
                {
                    {cout << """cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2"": " ; cout << x1 << " " << y1 << " " << x2 << " " << y2; cout << endl;};
                    {cout << """cout << complex<double>(x1, y1) * complex<double>(x2, y2)"": " ; cout << complex<double>(x1, y1) * complex<double>(x2, y2); cout << endl;};
                    cout << endl;
                }
                {cout << """cout << x1 << \" \" << y1 << \" \" << x2"": " ; cout << x1 << " " << y1 << " " << x2; cout << endl;};
                {cout << """cout << complex<double>(x1, y1) * x2"": " ; cout << complex<double>(x1, y1) * x2; cout << endl;};
                {cout << """cout << x2 * complex<double>(x1, y1)"": " ; cout << x2 * complex<double>(x1, y1); cout << endl;};
                cout << endl;
            }
    return 0;
}

Задание H

int main()
{
    {cout << """cout << 1_i / 2_i << endl"": " ; cout << 1_i / 2_i << endl; cout << endl;};
    {cout << """cout << 1.0 / 2_i << endl"": " ; cout << 1.0 / 2_i << endl; cout << endl;};
    {cout << """cout << 1_i / 2.0 << endl"": " ; cout << 1_i / 2.0 << endl; cout << endl;};
    {cout << """cout << 1_if / 2_if << endl"": " ; cout << 1_if / 2_if << endl; cout << endl;};
    {cout << """cout << 1.0F / 2_if << endl"": " ; cout << 1.0F / 2_if << endl; cout << endl;};
    {cout << """cout << 1_if / 2.0F << endl"": " ; cout << 1_if / 2.0F << endl; cout << endl;};
    {cout << """cout << 1e1000_il * 2e1000_il << endl"": " ; cout << 1e1000_il * 2e1000_il << endl; cout << endl;};
    {cout << """cout << 1e1000L * 2e1000_il << endl"": " ; cout << 1e1000L * 2e1000_il << endl; cout << endl;};
    {cout << """cout << 1e1000_il * 2e1000L << endl"": " ; cout << 1e1000_il * 2e1000L << endl; cout << endl;};
    for (double x1 = -2; x1 <= 2; x1 += 0.5)
        for (double y1 = -2; y1 <= 2; y1 += 0.5)
            for (double x2 = -2; x2 <= 2; x2 += 0.5)
            {
                for (double y2 = -2; y2 <= 2; y2 += 0.5)
                    if (x2 != 0 || y2 != 0)
                    {
                        {cout << """cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2"": " ; cout << x1 << " " << y1 << " " << x2 << " " << y2; cout << endl;};
                        {cout << """cout << complex<double>(x1, y1) / complex<double>(x2, y2)"": " ; cout << complex<double>(x1, y1) / complex<double>(x2, y2); cout << endl;};
                        cout << endl;
                    }
                {cout << """cout << x1 << \" \" << y1 << \" \" << x2"": " ; cout << x1 << " " << y1 << " " << x2; cout << endl;};
                if (x2 != 0)
                    {cout << """cout << complex<double>(x1, y1) / x2"": " ; cout << complex<double>(x1, y1) / x2; cout << endl;};
                if (x1 != 0 || y1 != 0)
                    {cout << """cout << x2 / complex<double>(x1, y1)"": " ; cout << x2 / complex<double>(x1, y1); cout << endl;};
                cout << endl;
            }
    return 0;
}

Задание I

int main()
{
    {cout << """cout << + 2_i << endl"": " ; cout << + 2_i << endl; cout << endl;};
    {cout << """cout << - 2_i << endl"": " ; cout << - 2_i << endl; cout << endl;};
    {cout << """cout << + 2_if << endl"": " ; cout << + 2_if << endl; cout << endl;};
    {cout << """cout << - 2_if << endl"": " ; cout << - 2_if << endl; cout << endl;};
    {cout << """cout << + 2e1000_il << endl"": " ; cout << + 2e1000_il << endl; cout << endl;};
    {cout << """cout << - 2e1000_il << endl"": " ; cout << - 2e1000_il << endl; cout << endl;};
    for (double x = -2; x <= 2; x += 0.5)
        for (double y = -2; y <= 2; y += 0.5)
        {
            complex<double> z;
            {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
            {cout << """cout << (z = complex<double>(x, y))"": " ; cout << (z = complex<double>(x, y)); cout << endl;};
            {cout << """cout << +z"": " ; cout << +z; cout << endl;};
            {cout << """cout << -z"": " ; cout << -z; cout << endl;};
            {cout << """cout << z"": " ; cout << z; cout << endl;};
            cout << endl;
        }
    return 0;
}

Задание J

int main()
{
    {cout << """cout << 2_i .abs() << endl"": " ; cout << 2_i .abs() << endl; cout << endl;};
    {cout << """cout << 2_i .arg() << endl"": " ; cout << 2_i .arg() << endl; cout << endl;};
    {cout << """cout << 2_if .abs() << endl"": " ; cout << 2_if .abs() << endl; cout << endl;};
    {cout << """cout << 2_if .arg() << endl"": " ; cout << 2_if .arg() << endl; cout << endl;};
    {cout << """cout << 2e1000_il .abs() << endl"": " ; cout << 2e1000_il .abs() << endl; cout << endl;};
    {cout << """cout << 2e1000_il .arg() << endl"": " ; cout << 2e1000_il .arg() << endl; cout << endl;};
    for (double x = -2; x <= 2; x += 0.5)
        for (double y = -2; y <= 2; y += 0.5)
        {
            complex<double> z;
            {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
            {cout << """cout << (z = complex<double>(x, y))"": " ; cout << (z = complex<double>(x, y)); cout << endl;};
            {cout << """cout << z.abs()"": " ; cout << z.abs(); cout << endl;};
            {cout << """cout << z.arg()"": " ; cout << z.arg(); cout << endl;};
            {cout << """cout << z"": " ; cout << z; cout << endl;};
            cout << endl;
        }
    return 0;
}

Задание K

int main()
{
    {cout << """cout << complex<double>::polar(1, 0) << endl"": " ; cout << complex<double>::polar(1, 0) << endl; cout << endl;};
    {cout << """cout << complex<long double>::polar(1, 0) << endl"": " ; cout << complex<long double>::polar(1, 0) << endl; cout << endl;};
    {cout << """cout << complex<float>::polar(1, 0) << endl"": " ; cout << complex<float>::polar(1, 0) << endl; cout << endl;};
    for (double r = 0; r <= 10; r += 0.5)
        for (double a = -10; a <= 10; a += 0.5)
        {
            complex<double> z;
            {cout << """cout << r << \" \" << a"": " ; cout << r << " " << a; cout << endl;};
            {cout << """cout << complex<double>::polar(r, a)"": " ; cout << complex<double>::polar(r, a); cout << endl;};
            cout << endl;
        }
    return 0;
}

Задание L

template<typename T>
string eq(complex<T> z, complex<T> w)
{
    if ((z - w).abs() < 1e-6)
        return "OK";
    else
        return "FAIL";
}
int main()
{
    for (double x = 0; x <= 10; x += 0.5)
        for (double y = -10; y <= 10; y += 0.5)
        {
            complex<double> z, w;
            {cout << """cout << (z = complex<double>(x, y))"": " ; cout << (z = complex<double>(x, y)); cout << endl;};
            {cout << """w = complex<double>::sqrt(z)"": " ; w = complex<double>::sqrt(z); cout << endl;};
            {cout << """cout << eq(w * w, z)"": " ; cout << eq(w * w, z); cout << endl;};
            cout << endl;
        }
    return 0;
}

Задание M

template<typename T>
bool eq(complex<T> z, complex<T> w)
{
    return ((z - w).abs() < 1e-6);
}
int main()
{
    const int M = 4;
    complex<double> x1, x2, zero;
    for (double ax = -M; ax <= M; ax += 0.5)
        for (double ay = -M; ay <= M; ay += 0.5)
            if (ax != 0 || ay != 0)
            {
                complex<double> a(ax, ay);
                for (double bx = -M; bx <= M; bx += 0.5)
                    for (double by = -M; by <= M; by += 0.5)
                    {
                        complex<double> b(bx, by);
                        for (double cx = -M; cx <= M; cx += 0.5)
                            for (double cy = -M; cy <= M; cy += 0.5)
                            {
                                complex<double> c(cx, cy);
                                complex<double>::solve_quadratic_equation(a, b, c, x1, x2);
                                if (!eq((x1 * x2) * a, c)
                                 || !eq((x1 + x2) * a, -b)
                                 || !eq(a * x1 * x1 + b * x1 + c, zero)
                                 || !eq(a * x2 * x2 + b * x2 + c, zero))
                                {
                                    cout << "FAIL on a = " << a << ", b = " << b << ", c = " << c << endl;
                                    return 0;
                                }
                            }
                    }
            }
    cout << "OK" << endl;
    return 0;
}

Задание N

int main()
{
    {cout << """cout << (1_i == 1_i) << endl"": " ; cout << (1_i == 1_i) << endl; cout << endl;};
    {cout << """cout << (1_i != 1_i) << endl"": " ; cout << (1_i != 1_i) << endl; cout << endl;};
    {cout << """cout << (1_i == 2_i) << endl"": " ; cout << (1_i == 2_i) << endl; cout << endl;};
    {cout << """cout << (1_i != 2_i) << endl"": " ; cout << (1_i != 2_i) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i == 1.0) << endl"": " ; cout << (1.0 + 0_i == 1.0) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i != 1.0) << endl"": " ; cout << (1.0 + 0_i != 1.0) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i == 2.0) << endl"": " ; cout << (1.0 + 0_i == 2.0) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i != 2.0) << endl"": " ; cout << (1.0 + 0_i != 2.0) << endl; cout << endl;};
    {cout << """cout << (1.0 == 1.0 + 0_i) << endl"": " ; cout << (1.0 == 1.0 + 0_i) << endl; cout << endl;};
    {cout << """cout << (1.0 == 1.0 + 0_i) << endl"": " ; cout << (1.0 == 1.0 + 0_i) << endl; cout << endl;};
    {cout << """cout << (2.0 == 1.0 + 0_i) << endl"": " ; cout << (2.0 == 1.0 + 0_i) << endl; cout << endl;};
    {cout << """cout << (2.0 == 1.0 + 0_i) << endl"": " ; cout << (2.0 == 1.0 + 0_i) << endl; cout << endl;};
    float eps_f = numeric_limits<float>::epsilon();
    double eps_d = numeric_limits<double>::epsilon();
    long double eps_l = numeric_limits<long double>::epsilon();
    {cout << """cout << (1.0F + 0_if == 1.0F + 0_if + eps_f) << endl"": " ; cout << (1.0F + 0_if == 1.0F + 0_if + eps_f) << endl; cout << endl;};
    {cout << """cout << (1.0F + 0_if == 1.0F + 0_if - eps_f) << endl"": " ; cout << (1.0F + 0_if == 1.0F + 0_if - eps_f) << endl; cout << endl;};
    {cout << """cout << (1.0F + 0_if != 1.0F + 0_if + eps_f) << endl"": " ; cout << (1.0F + 0_if != 1.0F + 0_if + eps_f) << endl; cout << endl;};
    {cout << """cout << (1.0F + 0_if != 1.0F + 0_if - eps_f) << endl"": " ; cout << (1.0F + 0_if != 1.0F + 0_if - eps_f) << endl; cout << endl;};
    {cout << """cout << (1_if == 1_if + eps_f * 1_if) << endl"": " ; cout << (1_if == 1_if + eps_f * 1_if) << endl; cout << endl;};
    {cout << """cout << (1_if == 1_if - eps_f * 1_if) << endl"": " ; cout << (1_if == 1_if - eps_f * 1_if) << endl; cout << endl;};
    {cout << """cout << (1_if != 1_if + eps_f * 1_if) << endl"": " ; cout << (1_if != 1_if + eps_f * 1_if) << endl; cout << endl;};
    {cout << """cout << (1_if != 1_if - eps_f * 1_if) << endl"": " ; cout << (1_if != 1_if - eps_f * 1_if) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i == 1.0 + 0_i + eps_d) << endl"": " ; cout << (1.0 + 0_i == 1.0 + 0_i + eps_d) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i == 1.0 + 0_i - eps_d) << endl"": " ; cout << (1.0 + 0_i == 1.0 + 0_i - eps_d) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i != 1.0 + 0_i + eps_d) << endl"": " ; cout << (1.0 + 0_i != 1.0 + 0_i + eps_d) << endl; cout << endl;};
    {cout << """cout << (1.0 + 0_i != 1.0 + 0_i - eps_d) << endl"": " ; cout << (1.0 + 0_i != 1.0 + 0_i - eps_d) << endl; cout << endl;};
    {cout << """cout << (1_i == 1_i + eps_d * 1_i) << endl"": " ; cout << (1_i == 1_i + eps_d * 1_i) << endl; cout << endl;};
    {cout << """cout << (1_i == 1_i - eps_d * 1_i) << endl"": " ; cout << (1_i == 1_i - eps_d * 1_i) << endl; cout << endl;};
    {cout << """cout << (1_i != 1_i + eps_d * 1_i) << endl"": " ; cout << (1_i != 1_i + eps_d * 1_i) << endl; cout << endl;};
    {cout << """cout << (1_i != 1_i - eps_d * 1_i) << endl"": " ; cout << (1_i != 1_i - eps_d * 1_i) << endl; cout << endl;};
    {cout << """cout << (1.0L + 0_il == 1.0L + 0_il + eps_l) << endl"": " ; cout << (1.0L + 0_il == 1.0L + 0_il + eps_l) << endl; cout << endl;};
    {cout << """cout << (1.0L + 0_il == 1.0L + 0_il - eps_l) << endl"": " ; cout << (1.0L + 0_il == 1.0L + 0_il - eps_l) << endl; cout << endl;};
    {cout << """cout << (1.0L + 0_il != 1.0L + 0_il + eps_l) << endl"": " ; cout << (1.0L + 0_il != 1.0L + 0_il + eps_l) << endl; cout << endl;};
    {cout << """cout << (1.0L + 0_il != 1.0L + 0_il - eps_l) << endl"": " ; cout << (1.0L + 0_il != 1.0L + 0_il - eps_l) << endl; cout << endl;};
    {cout << """cout << (1_il == 1_il + eps_l * 1_il) << endl"": " ; cout << (1_il == 1_il + eps_l * 1_il) << endl; cout << endl;};
    {cout << """cout << (1_il == 1_il - eps_l * 1_il) << endl"": " ; cout << (1_il == 1_il - eps_l * 1_il) << endl; cout << endl;};
    {cout << """cout << (1_il != 1_il + eps_l * 1_il) << endl"": " ; cout << (1_il != 1_il + eps_l * 1_il) << endl; cout << endl;};
    {cout << """cout << (1_il != 1_il - eps_l * 1_il) << endl"": " ; cout << (1_il != 1_il - eps_l * 1_il) << endl; cout << endl;};
    {cout << """cout << (1_if == 1_if) << endl"": " ; cout << (1_if == 1_if) << endl; cout << endl;};
    {cout << """cout << (1_if != 1_if) << endl"": " ; cout << (1_if != 1_if) << endl; cout << endl;};
    {cout << """cout << (1_if == 2_if) << endl"": " ; cout << (1_if == 2_if) << endl; cout << endl;};
    {cout << """cout << (1_if != 2_if) << endl"": " ; cout << (1_if != 2_if) << endl; cout << endl;};
    {cout << """cout << (1.0F + 0_if == 1.0F) << endl"": " ; cout << (1.0F + 0_if == 1.0F) << endl; cout << endl;};
    {cout << """cout << (1.0F + 0_if != 1.0F) << endl"": " ; cout << (1.0F + 0_if != 1.0F) << endl; cout << endl;};
    {cout << """cout << (1.0F + 0_if == 2.0F) << endl"": " ; cout << (1.0F + 0_if == 2.0F) << endl; cout << endl;};
    {cout << """cout << (1.0F + 0_if != 2.0F) << endl"": " ; cout << (1.0F + 0_if != 2.0F) << endl; cout << endl;};
    {cout << """cout << (1.0F == 1.0F + 0_if) << endl"": " ; cout << (1.0F == 1.0F + 0_if) << endl; cout << endl;};
    {cout << """cout << (1.0F == 1.0F + 0_if) << endl"": " ; cout << (1.0F == 1.0F + 0_if) << endl; cout << endl;};
    {cout << """cout << (2.0F == 1.0F + 0_if) << endl"": " ; cout << (2.0F == 1.0F + 0_if) << endl; cout << endl;};
    {cout << """cout << (2.0F == 1.0F + 0_if) << endl"": " ; cout << (2.0F == 1.0F + 0_if) << endl; cout << endl;};
    {cout << """cout << (1e1000_il == 1e1000_il) << endl"": " ; cout << (1e1000_il == 1e1000_il) << endl; cout << endl;};
    {cout << """cout << (1e1000_il != 1e1000_il) << endl"": " ; cout << (1e1000_il != 1e1000_il) << endl; cout << endl;};
    {cout << """cout << (1e1000_il == 2e1000_il) << endl"": " ; cout << (1e1000_il == 2e1000_il) << endl; cout << endl;};
    {cout << """cout << (1e1000_il != 2e1000_il) << endl"": " ; cout << (1e1000_il != 2e1000_il) << endl; cout << endl;};
    {cout << """cout << (1.0e1000L + 0_il == 1.0e1000L) << endl"": " ; cout << (1.0e1000L + 0_il == 1.0e1000L) << endl; cout << endl;};
    {cout << """cout << (1.0e1000L + 0_il != 1.0e1000L) << endl"": " ; cout << (1.0e1000L + 0_il != 1.0e1000L) << endl; cout << endl;};
    {cout << """cout << (1.0e1000L + 0_il == 2.0e1000L) << endl"": " ; cout << (1.0e1000L + 0_il == 2.0e1000L) << endl; cout << endl;};
    {cout << """cout << (1.0e1000L + 0_il != 2.0e1000L) << endl"": " ; cout << (1.0e1000L + 0_il != 2.0e1000L) << endl; cout << endl;};
    {cout << """cout << (1.0e1000L == 1.0e1000L + 0_il) << endl"": " ; cout << (1.0e1000L == 1.0e1000L + 0_il) << endl; cout << endl;};
    {cout << """cout << (1.0e1000L == 1.0e1000L + 0_il) << endl"": " ; cout << (1.0e1000L == 1.0e1000L + 0_il) << endl; cout << endl;};
    {cout << """cout << (2.0e1000L == 1.0e1000L + 0_il) << endl"": " ; cout << (2.0e1000L == 1.0e1000L + 0_il) << endl; cout << endl;};
    {cout << """cout << (2.0e1000L == 1.0e1000L + 0_il) << endl"": " ; cout << (2.0e1000L == 1.0e1000L + 0_il) << endl; cout << endl;};
    for (double x1 = -2; x1 <= 2; x1 += 0.5)
        for (double y1 = -2; y1 <= 2; y1 += 0.5)
            for (double x2 = -2; x2 <= 2; x2 += 0.5)
            {
                for (double y2 = -2; y2 <= 2; y2 += 0.5)
                {
                    {cout << """cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2"": " ; cout << x1 << " " << y1 << " " << x2 << " " << y2; cout << endl;};
                    {cout << """cout << (complex<double>(x1, y1) == complex<double>(x2, y2))"": " ; cout << (complex<double>(x1, y1) == complex<double>(x2, y2)); cout << endl;};
                    {cout << """cout << (complex<double>(x1, y1) != complex<double>(x2, y2))"": " ; cout << (complex<double>(x1, y1) != complex<double>(x2, y2)); cout << endl;};
                    cout << endl;
                }
                {cout << """cout << x1 << \" \" << y1 << \" \" << x2"": " ; cout << x1 << " " << y1 << " " << x2; cout << endl;};
                {cout << """cout << (complex<double>(x1, y1) == x2)"": " ; cout << (complex<double>(x1, y1) == x2); cout << endl;};
                {cout << """cout << (complex<double>(x1, y1) != x2)"": " ; cout << (complex<double>(x1, y1) != x2); cout << endl;};
                {cout << """cout << (x2 == complex<double>(x1, y1))"": " ; cout << (x2 == complex<double>(x1, y1)); cout << endl;};
                {cout << """cout << (x2 != complex<double>(x1, y1))"": " ; cout << (x2 != complex<double>(x1, y1)); cout << endl;};
                cout << endl;
            }
    return 0;
}

Задание O

int main()
{
    {cout << """cout << (1_i < 1_i) << endl"": " ; cout << (1_i < 1_i) << endl; cout << endl;};
    {cout << """cout << (1_if < 1_if) << endl"": " ; cout << (1_if < 1_if) << endl; cout << endl;};
    {cout << """cout << (1e1000_il < 1e1000_il) << endl"": " ; cout << (1e1000_il < 1e1000_il) << endl; cout << endl;};
    for (double x1 = -2; x1 <= 2; x1 += 0.5)
        for (double y1 = -2; y1 <= 2; y1 += 0.5)
            for (double x2 = -2; x2 <= 2; x2 += 0.5)
            {
                for (double y2 = -2; y2 <= 2; y2 += 0.5)
                {
                    {cout << """cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2"": " ; cout << x1 << " " << y1 << " " << x2 << " " << y2; cout << endl;};
                    {cout << """cout << (complex<double>(x1, y1) < complex<double>(x2, y2))"": " ; cout << (complex<double>(x1, y1) < complex<double>(x2, y2)); cout << endl;};
                    cout << endl;
                }
            }
    vector <complex<double> > a;
    for (double x = -10; x <= 10; x += 0.5)
        for (double y = -10; y <= 10; y += 0.5)
            a.push_back(complex<double>(x, y));
    sort(a.begin(), a.end());
    for (int i = 0; i < a.size(); ++i)
        cout << a[i] << endl;
    return 0;
}

Задание P

int main()
{
    {cout << """cout << complex<double>::pow(1_i, 2) << endl"": " ; cout << complex<double>::pow(1_i, 2) << endl; cout << endl;};
    {cout << """cout << complex<float>::pow(1_if, 2) << endl"": " ; cout << complex<float>::pow(1_if, 2) << endl; cout << endl;};
    {cout << """cout << complex<long double>::pow(1_il, 2) << endl"": " ; cout << complex<long double>::pow(1_il, 2) << endl; cout << endl;};
    for (double x = -5; x <= 5; x += 0.5)
        for (double y = -5; y <= 5; y += 0.5)
            for (int n = -10; n <= 10; ++n)
                if (n > 0 || x != 0 || y != 0)
                {
                    {cout << """cout << x << \" \" << y << \" \" << n"": " ; cout << x << " " << y << " " << n; cout << endl;};
                    {cout << """cout << complex<long double>::pow(complex<long double>(x, y), n)"": " ; cout << complex<long double>::pow(complex<long double>(x, y), n); cout << endl;};
                }
    for (int i = 0; i < 10; ++i)
    {
        complex<long double> a = complex<long double>::polar(1.001, 0.1 * i);
        for (int n = 1000; n <= 3000; ++n)
        {
            cout << complex<long double>::pow(a, n) << endl;
        }
    }
    return 0;
}

Задание Q

int main()
{
    cout << fixed;
    {cout << """cout << complex<double>::pow(1_i, (double)2.5) << endl"": " ; cout << complex<double>::pow(1_i, (double)2.5) << endl; cout << endl;};
    {cout << """cout << complex<float>::pow(1_if, (float)2.5) << endl"": " ; cout << complex<float>::pow(1_if, (float)2.5) << endl; cout << endl;};
    {cout << """cout << complex<long double>::pow(1_il, (long double)2.5) << endl"": " ; cout << complex<long double>::pow(1_il, (long double)2.5) << endl; cout << endl;};
    for (long double x = -5; x <= 5; x += 0.45)
        for (long double y = -5; y <= 5; y += 0.45)
            for (long double p = -3; p <= 3; p += 0.26)
            {
                if (x != 0 || y != 0 || p != 0)
                {
                    {cout << """cout << x << \" \" << y << \" \" << p"": " ; cout << x << " " << y << " " << p; cout << endl;};
                    {cout << """cout << complex<long double>::pow(complex<long double>(x, y), p)"": " ; cout << complex<long double>::pow(complex<long double>(x, y), p); cout << endl;};
                }
            }
    return 0;
}

Задание R

int main()
{
    cout << fixed;
    {cout << """cout << complex<double>::exp(1_i) << endl"": " ; cout << complex<double>::exp(1_i) << endl; cout << endl;};
    {cout << """cout << complex<float>::exp(1_if) << endl"": " ; cout << complex<float>::exp(1_if) << endl; cout << endl;};
    {cout << """cout << complex<long double>::exp(1_il) << endl"": " ; cout << complex<long double>::exp(1_il) << endl; cout << endl;};
    for (long double x = -5; x <= 5; x += 0.25)
        for (long double y = -5; y <= 5; y += 0.25)
        {
            {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
            {cout << """cout << complex<long double>::exp(complex<long double>(x, y))"": " ; cout << complex<long double>::exp(complex<long double>(x, y)); cout << endl;};
        }
    return 0;
}

Задание S

int main()
{
    cout << fixed;
    {cout << """cout << complex<double>::sin(1_i) << endl"": " ; cout << complex<double>::sin(1_i) << endl; cout << endl;};
    {cout << """cout << complex<float>::sin(1_if) << endl"": " ; cout << complex<float>::sin(1_if) << endl; cout << endl;};
    {cout << """cout << complex<long double>::sin(1_il) << endl"": " ; cout << complex<long double>::sin(1_il) << endl; cout << endl;};
    for (long double x = -5; x <= 5; x += 0.25)
        for (long double y = -5; y <= 5; y += 0.25)
        {
            {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
            {cout << """cout << complex<long double>::sin(complex<long double>(x, y))"": " ; cout << complex<long double>::sin(complex<long double>(x, y)); cout << endl;};
        }
    return 0;
}

Задание T

int main()
{
    cout << fixed;
    {cout << """cout << complex<double>::cos(1_i) << endl"": " ; cout << complex<double>::cos(1_i) << endl; cout << endl;};
    {cout << """cout << complex<float>::cos(1_if) << endl"": " ; cout << complex<float>::cos(1_if) << endl; cout << endl;};
    {cout << """cout << complex<long double>::cos(1_il) << endl"": " ; cout << complex<long double>::cos(1_il) << endl; cout << endl;};
    for (long double x = -5; x <= 5; x += 0.25)
        for (long double y = -5; y <= 5; y += 0.25)
        {
            {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
            {cout << """cout << complex<long double>::cos(complex<long double>(x, y))"": " ; cout << complex<long double>::cos(complex<long double>(x, y)); cout << endl;};
        }
    return 0;
}

Задание U

int main()
{
    cout << fixed;
    {cout << """cout << complex<double>::log(1_i) << endl"": " ; cout << complex<double>::log(1_i) << endl; cout << endl;};
    {cout << """cout << complex<float>::log(1_if) << endl"": " ; cout << complex<float>::log(1_if) << endl; cout << endl;};
    {cout << """cout << complex<long double>::log(1_il) << endl"": " ; cout << complex<long double>::log(1_il) << endl; cout << endl;};
    for (long double x = -5; x <= 5; x += 0.25)
        for (long double y = -5; y <= 5; y += 0.25)
            if (x != 0 || y != 0)
            {
                {cout << """cout << x << \" \" << y"": " ; cout << x << " " << y; cout << endl;};
                {cout << """cout << complex<long double>::log(complex<long double>(x, y))"": " ; cout << complex<long double>::log(complex<long double>(x, y)); cout << endl;};
            }
    return 0;
}

Задание V

int main()
{
    cout << fixed;
    {cout << """cout << complex<double>::pow(complex<double>(1, 1.5), complex<double>(2)) << endl"": " ; cout << complex<double>::pow(complex<double>(1, 1.5), complex<double>(2)) << endl; cout << endl;};
    {cout << """cout << complex<float>::pow(complex<float>(1, 1.5), complex<float>(2)) << endl"": " ; cout << complex<float>::pow(complex<float>(1, 1.5), complex<float>(2)) << endl; cout << endl;};
    {cout << """cout << complex<long double>::pow(complex<long double>(1, 1.5), complex<long double>(2)) << endl"": " ; cout << complex<long double>::pow(complex<long double>(1, 1.5), complex<long double>(2)) << endl; cout << endl;};
    for (long double x1 = -2; x1 <= 2; x1 += 0.45)
        for (long double y1 = -2; y1 <= 2; y1 += 0.45)
            for (long double x2 = -2; x2 <= 2; x2 += 0.45)
                for (long double y2 = -2; y2 <= 2; y2 += 0.45)
                    if (x1 != 0 || y1 != 0)
                    {
                        {cout << """cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2"": " ; cout << x1 << " " << y1 << " " << x2 << " " << y2; cout << endl;};
                        {cout << """cout << complex<long double>::pow(complex<long double>(x1, y1), complex<long double>(x2, y2))"": " ; cout << complex<long double>::pow(complex<long double>(x1, y1), complex<long double>(x2, y2)); cout << endl;};
                        cout << endl;
                    }
    return 0;
}

Задание Y

int main()
{
    complex <long double> _z;
    while (cin >> _z)
        cout << _z << endl;
    cout << "=== Testing stringstream === " << endl;
    istringstream _s("1 1i 0 0i (1+1i) (1) (0) (-i) (-1-i) (-1-0i) (1.0+1.0e2i)");
    while (_s >> _z)
        cout << _z << endl;
    return 0;
}

Задание Z

template<typename T>
bool eq(complex<T> z, complex<T> w)
{
    return ((z - w).abs() < 1e-4);
}
int main()
{
    const int M = 2, N = 4;
    complex<double> x1, x2, x3, zero;
    for (double ax = -M; ax <= M; ax += 0.5)
        for (double ay = -M; ay <= M; ay += 0.5)
            if (ax != 0 || ay != 0)
            {
                complex<double> a(ax, ay);
                for (double bx = -M; bx <= M; bx += 0.5)
                    for (double by = -M; by <= M; by += 0.5)
                    {
                        complex<double> b(bx, by);
                        for (double cx = -M; cx <= M; cx += 0.5)
                            for (double cy = -M; cy <= M; cy += 0.5)
                            {
                                complex<double> c(cx, cy);
                                for (double dx = -M; dx <= M; dx += 0.5)
                                    for (double dy = -M; dy <= M; dy += 0.5)
                                    {
                                        complex<double> d(dx, dy);
                                        complex<double>::solve_cubic_equation(a, b, c, d, x1, x2, x3);
                                        if (!eq((x1 * x2 * x3) * a, -d)
                                             || !eq((x1 * x2 + x2 * x3 + x3 * x1) * a, c)
                                             || !eq((x1 + x2 + x3) * a, -b)
                                             || !eq(a * x1 * x1 * x1 + b * x1 * x1 + c * x1 + d, zero)
                                             || !eq(a * x2 * x2 * x2 + b * x2 * x2 + c * x2 + d, zero)
                                             || !eq(a * x3 * x3 * x3 + b * x3 * x3 + c * x3 + d, zero))
                                            {
                                                cout << "FAIL on a = " << a << ", b = " << b << ", c = " << c << ", d = " << d << endl;
                                                cout << "Your answer: " << endl;
                                                cout << "x1 = " << x1 << endl;
                                                cout << "x2 = " << x2 << endl;
                                                cout << "x3 = " << x3 << endl;
                                                return 0;
                                            }
                                    }
                            }
                    }
            }
    complex<double> a(1), b, c, d;
    for (double ax = -N; ax <= N; ax += 0.5)
        for (double ay = -N; ay <= N; ay += 0.5)
        {
            complex<double> z1(ax, ay);
            for (double bx = -N; bx <= N; bx += 0.5)
                for (double by = -N; by <= N; by += 0.5)
                {
                    complex<double> z2(bx, by);
                    for (double cx = -N; cx <= N; cx += 0.5)
                        for (double cy = -N; cy <= N; cy += 0.5)
                        {
                            complex<double> z3(cx, cy);
                            b = -(z1 + z2 + z3);
                            c = (z1 * z2 + z2 * z3 + z3 * z1);
                            d = -(z1 * z2 * z3);
                            complex<double>::solve_cubic_equation(a, b, c, d, x1, x2, x3);
                            if (!eq((x1 * x2 * x3) * a, -d)
                                 || !eq((x1 * x2 + x2 * x3 + x3 * x1) * a, c)
                                 || !eq((x1 + x2 + x3) * a, -b)
                                 || !eq(a * x1 * x1 * x1 + b * x1 * x1 + c * x1 + d, zero)
                                 || !eq(a * x2 * x2 * x2 + b * x2 * x2 + c * x2 + d, zero)
                                 || !eq(a * x3 * x3 * x3 + b * x3 * x3 + c * x3 + d, zero))
                                {
                                    cout << "FAIL on a = " << a << ", b = " << b << ", c = " << c << ", d = " << d << endl;
                                    cout << "Your answer: " << endl;
                                    cout << "x1 = " << x1 << endl;
                                    cout << "x2 = " << x2 << endl;
                                    cout << "x3 = " << x3 << endl;
                                    return 0;
                                }
                        }
                }
        }
    cout << "OK" << endl;
    return 0;
}