Advertisement
Guest User

Help

a guest
Jan 4th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main() {
  5.     int n, k = 3, count = 0;
  6.     double ak, ak_1 = 3, ak_2 = 2, ak_3 = 1, s = 0;
  7.     cout<<"n = ";cin>>n;
  8.     while(n<=3)
  9.     {
  10.         cout<<"n = ";cin>>n;
  11.     }
  12.     cout<<"k = ";cin>>k;
  13.    
  14.     do
  15.     {
  16.         ak=sin(3.14/k*ak_2) - ak_1;
  17.         ak_3=ak_2;
  18.         ak_2=ak_1;
  19.         ak_1=ak;
  20.         count++;
  21.         k++;
  22.         s += ak;
  23.     }
  24.     while(k<=n);
  25.     s /= count;
  26.     cout<<"SA = "<<s;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement