Advertisement
konevLOX

5.3.1

Dec 2nd, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. static int fact(int a)
  2. {
  3. int f = 1;
  4. for (int i = 1; i <= a; i++)
  5. {
  6. f *= i;
  7. }
  8. return f;
  9. }
  10. delegate double si(int i,double x);
  11. static double s1(int i,double x)
  12. {
  13. return Math.Cos(i * x) / fact(i);
  14. }
  15. static double s2(int i, double x)
  16. {
  17. return Math.Pow(-1, i) * Math.Cos(i * x) / (i * i);
  18. }
  19. static double summa(si s, double sum, int n,double x, double h)
  20. {
  21. for (int i = 1; i <= n; i++)
  22. {
  23. sum += s(i, x);
  24. x += h;
  25. }
  26. return sum;
  27. }
  28. static void Main(string[] args)
  29. {
  30. double sum1 = summa(s1, 1, 10, 0.1, 0.1);
  31. WriteLine();
  32. double sum2 = summa(s2, 0, 20, Math.PI / 5, Math.PI / 25);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement