Advertisement
STANAANDREY

ex8

Jan 19th, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. { // problema 8
  6.  long S,p,c;
  7.  unsigned n,i;
  8.  S=0;p=1;c=1;
  9.  cout<<"n=";cin>>n;
  10.  for (i=1;i<=n;i++)
  11.  {
  12.     p*=i;
  13.     S+=c*p*p;
  14.     c*=-1;
  15.  }
  16.   cout<<"S="<<S;
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement