fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. double S=0, E=0.00001, x, a, a1;
  7. int k=1;
  8. cout<<"Input x "<<endl ;
  9. cin>>x;
  10. a=pow(x,3)/2 ;
  11. do
  12. { a1=a;
  13. a=(-1)*x*x/(2*k+1)/(2*k+2);
  14. S+=a;
  15. k++;
  16. } while( fabs(a1-a)>E );
  17. cout<<"Summa= "<<S<<endl;
  18. cout<<"kol="<<k<<endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 4400KB
stdin
1.5
stdout
Input x 
Summa= -0.423387
kol=50