Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <cmath>
- using namespace std;
- double factor(int n){
- double ans = 1;
- for (int i = 1; i <= n; i++)
- ans *= double(i);
- return ans;
- }
- double sin_value (int n, double x){ // n - точность, x - в какой точке вычисляем синус
- double ans = 0;
- for (int i = 0; i < n; i++){
- if (i%2 == 0)
- ans+= pow(x,2*i+1)/factor(i);
- else
- ans-= pow(x,2*i+1)/factor(i);
- }
- return ans;
- }
- void vova_privet_ya_nihuya_ne_umeu_kodit(){
- int n,x;
- cin >> n >> x;
- cout << sin_value(n, x) << endl;
- }
- int main(){
- vova_privet_ya_nihuya_ne_umeu_kodit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement