Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int fact(int arg)
  8. {
  9.     if(arg < 0)
  10.         return 0;
  11.     if (arg == 0)
  12.         return 1;
  13.     else
  14.         if (arg>2)
  15.         {
  16.       return arg * fact(arg - 1);
  17.         }
  18. }
  19.  
  20. double perv(int a, double x)
  21. {
  22.     double zn = 0;
  23.     double sum = 0;
  24.   for (int i = 0; i < 5; i++)
  25.   {
  26.       zn = (pow(-1.0, i)/(fact(i)*fact(i + a)))*pow((x/2), 2*i + a);
  27.          sum += zn;
  28.   }
  29.   return sum;
  30. }
  31.  
  32. double vtor(int a,double x)
  33. {
  34.     double b = 0;
  35.     double cs = cos((a/(57.3))*(3.14159));
  36.     double sn = sin((a/(57.3))*(3.14159));
  37.     if (a % 2 == 0)
  38.         b = (perv(a,x)*cs - perv(a,x))/sn;
  39.     else
  40.         b = (perv(a,x)*cs + perv(a,x))/sn;
  41.     return b;
  42. }
  43. double itog(int a,double x)
  44. {
  45.     return perv(a,x) + vtor(a,x);
  46. }
  47. int main()
  48. {
  49.     cout << itog(4,3.0) << endl;
  50.     system("pause");
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement