Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. double factor(int n){
  8. double ans = 1;
  9. for (int i = 1; i <= n; i++)
  10. ans *= double(i);
  11. return ans;
  12. }
  13.  
  14. double sin_value (int n, double x){ // n - точность, x - в какой точке вычисляем синус
  15. double ans = 0;
  16. for (int i = 0; i < n; i++){
  17. if (i%2 == 0)
  18. ans+= pow(x,2*i+1)/factor(i);
  19. else
  20. ans-= pow(x,2*i+1)/factor(i);
  21. }
  22. return ans;
  23. }
  24.  
  25. void vova_privet_ya_nihuya_ne_umeu_kodit(){
  26. int n,x;
  27. cin >> n >> x;
  28. cout << sin_value(n, x) << endl;
  29. }
  30.  
  31. int main(){
  32. vova_privet_ya_nihuya_ne_umeu_kodit();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement