Quipex icon

Laba_3.6_II

Quipex | PRO | 10/06/15 08:33:00 PM UTC | 0 ⭐ | 294 👁️ | Never ⏰ | []
C++ |

670 B

|

None

|

0 👍

/

0 👎

// Laba_3.6_II_var.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <math.h>
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()
{
    double a,b,y,s,x,h,p;
    int n;
    cout<<"Vvedite a, b, n:\n";
    cin>>a>>b>>n;
    h=(b-a)/10;
    x=a;
    int i;
    do
    {
        s=0;
        for(i=0;i<=n;i++)
        {
            p=pow(x,2*i)/fact(2*i);
            s+=p;
            //cout<<s;
        }
        y=(exp(x)+exp(-x))/2;
        x+=h;
        cout<<setw(15)<<s<<setw(15)<<y<<endl;
    }
    while(x<b);
    system("pause");
    return 0;
}

Comments