Advertisement
Derga

Untitled

Feb 27th, 2023 (edited)
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. /*
  2. Задание 2.
  3. */
  4.  
  5. #include <cmath>
  6. #include <iomanip>
  7. #include <iostream>
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12.     size_t n;
  13.     cin >> n;
  14.  
  15.     if (n == 0) {
  16.         cout << "The division by 0 operation is not possible";
  17.         return 0;
  18.     }
  19.  
  20.     double result = 0;
  21.     double sin_sum = 0;
  22.     for (int i = 1; i <= n; ++i) {
  23.         sin_sum += sin(i);
  24.         result += cos(i) / sin_sum;
  25.     }
  26.    
  27.     const int PRECISION = 15;
  28.     cout << fixed << setprecision(PRECISION) << result;
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement