STANAANDREY

T_pb22

Dec 10th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.  
  8. float S=0;
  9. long x,n,i,p,nr,cp;
  10. i=1;p=1;nr=1;
  11.  
  12. cout<<"x=";cin>>x;
  13. cout<<"n=";cin>>n;
  14.  
  15. while (i<=n)
  16. {
  17.      nr=1;
  18.     cp=p;
  19.     do
  20.     {
  21.         nr*=x;
  22.         cp--;
  23.     } while (cp!=0);
  24.  
  25.     S+=(float)nr/(float)p;
  26.     p+=2;
  27.     i++;
  28. }
  29. cout<<"S="<<S;
  30. return 0;
  31. }
Add Comment
Please, Sign In to add comment