Advertisement
STANAANDREY

21d)met1

Dec 10th, 2018
249
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.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.  unsigned long n,E=0,i=1;
  9.  
  10.  cout<<"n=";cin>>n;
  11.  
  12.  while (i<=n)
  13.  {
  14.      if (i%2==0)
  15.         E-=2*i;
  16.      else
  17.         E+=2*i;
  18.      i++;
  19.  }
  20. cout<<"E="<<E;
  21.  
  22. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement