Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- typedef double (*TFun)(double);
- double fun1(double x);
- double Factorial(int k, double rez);
- void Out(TFun,double a,double b,double h);
- double fun2(double n,double x);
- int main()
- {
- double a, b, h;
- int n,kod;
- cout << "Input a: " << endl;
- cin >> a;
- cout << "Input b: " << endl;
- cin >> b;
- cout << "Input n: " << endl;
- cin >> n;
- cout << "Input h: " << endl;
- cin >> h;
- cout<< "Y(x) - 0 "<<endl;
- cout<< "S(x) - 1 "<<endl;
- cin>>kod;
- switch(kod)
- {
- case 0:
- {
- cout << " Y(x): "<<endl;
- Out(fun1,a,b,h);
- }break;
- case 1:
- {
- cout << " S(x): "<<endl;
- Out(fun1,a,b,h);
- }break;
- }
- }
- double fun2(double n,double x)
- {
- double summ=0,rez;
- int k;
- for (k = 0; k <= n; k++)
- {
- summ = 0;rez=1;
- rez= Factorial(k,rez);
- summ += pow((2 * x), k) / rez ;
- }
- return summ;
- }
- void Out(TFun,double a,double b,double h)
- {
- double x;
- for (x = a; x <= b; x += h)
- {
- cout <<fun1(x)<<endl;
- }
- }
- double fun1(double x)
- {
- return exp (2 * x);
- }
- double Factorial(int numb,double rez)
- {
- int i;
- for ( i = numb; i != 0; i -- )
- {
- rez = rez * numb;
- numb--;
- }
- return rez;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement