• Программирование
    (visual studio 2012. C++)
    Один любой вариант. Хелп

    question img

Ответы 1

  • #include "stdafx.h"

    #include <iostream>

    #include <cmath>

    # define M_PIl          3.141592653589793238462643383279502884L

    using namespace std;

    long double fact(int N)

    {

    if (N < 0)

     return 0;

    if (N == 0)

     return 1;

    else

     return N * fact(N - 1);

    }

    int main()

    {

    cout << " n = ";

    int n; cin >> n;

    cout << " h = ";

    float h; cin >> h;

    float x = 0; int i = 1; float S = 1;

    if (n == 0)

    {

     cout << "S(" << x << ") = " << 0 << endl;

    }

    else

    {

     while ((x <= 1) && (i <= n))

     {

      S += (cos(i*(M_PIl / 4)) / fact(i))*pow(x, i);

      cout << "S(" << x << ") = " << S << endl;

      x = x + h;

      i = i + 1;

     }

    }

       return 0;

    }

    answer img
  • Добавить свой ответ

Еще вопросы

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years