fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. float REC(float,int);
  5. int main()
  6. {
  7. float U1,U2,S,x,eps;
  8. int N;
  9. printf("Vkajit x ta eps ");
  10. scanf("%f%f", &x,&eps);
  11. U1=x*x;
  12. N=1;
  13. S=U1;
  14. while(1)
  15. {
  16. N=N+1;
  17. U2=REC(x,N);
  18. S=S+U2;
  19. if (fabs(U1-U2)<eps&&N>2) break;
  20. U1=U2;
  21. }
  22. printf("x=%6.2f \n eps=%6.5f \n N=%d \n S=%9.5f",x,eps,N,S);
  23. scanf("%d", &N);
  24. }
  25. float REC(float x, int m)
  26. { if(m==1)
  27. return x*x;
  28. else return -REC(x,m-1)*x*x*x*x/((2*m-2)*(2*m-1));
  29. }
Success #stdin #stdout 0s 3144KB
stdin
0.1 0.03
stdout
Vkajit x ta eps x=  0.10 
 eps=0.03000 
 N=3 
 S=  0.01000